Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7549934rdb; Wed, 3 Jan 2024 23:00:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGH5Q92uEJHxbVkDXCKO2hGSdeKm6sni8MJoRiQvt+3pcCk9wWPu/PKyXDH+y7ePWvogm/q X-Received: by 2002:a17:902:6548:b0:1d4:3b76:be90 with SMTP id d8-20020a170902654800b001d43b76be90mr118972pln.39.1704351654381; Wed, 03 Jan 2024 23:00:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704351654; cv=none; d=google.com; s=arc-20160816; b=IYnPF56z35UGU2AE2hJRg8W/6sD6NfNnJrjgfm5m1hOX9CjcfCVKJrnuiyrTecR/oW heaupiEVPWc87fR1uEYqNUshAj0amzsVDTLIv1xzkSWUEh/cMj5Kfyd2+PRRB6Vi2X8I kRr+qL2SYPlgI8556+zPZWYMtcFIjJ76LytlGhJmvY7vigx07vm/HtaY14ehUcgq61Iz 58hfHJg/ffNCcgpQXV3ydYL70cR16RrRE8uyMlMxkdJGkIkeLjumm8z8rduANpIyAvzv 8I2wAyFQBBdginEnPmVwRpyLFalitTnqBn+MYgWVfsLc+nUVRbiggAUYP15S9oLfKoun F7pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=AvGkACQcr2iyTESCDfvJI1c7IEOTfjYcidY62BG+hQg=; fh=OaeWfznxMA9ploJoaNIYX3YJrBKVsRlCgCyqUxFpE9k=; b=Kb5ln03Dj58mRi5Qdh2aFERuJsBAMk4TFBLczle5lQDYP6igR/TqVgeZ+Y54AWUviu DB/v8vO7MzMTITviFcWIssP5KwrhUYKt9rDZ5iPkYAI9yuE0GXi0cgTsPAfUx4IjHGk7 y43J3s4VQqEEIU4ACMjdTqUxlpG+cWtvHRlbqFyB0YGVmR8p4bOPkMEqA6WBtL2PI6qc wQbwe8VXX97k3AdOVRcBkJJJioIemnR1SGIdUBbzelhXW5UvFKXDfGrgMdmqSKweY6Of A/8nG6wHT0qf8uj7THEOWlBheo4KgGAJMGlG/DiWTT46OPVUiBg+lfta8q72oZ59CIbp +S/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=qkM+vHPC; spf=pass (google.com: domain of linux-kernel+bounces-16296-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16296-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g24-20020a170902fe1800b001d3c3b750f7si21733180plj.332.2024.01.03.23.00.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 23:00:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16296-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=qkM+vHPC; spf=pass (google.com: domain of linux-kernel+bounces-16296-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16296-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 632C7288DB2 for ; Thu, 4 Jan 2024 06:51:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E88F81DFEC; Thu, 4 Jan 2024 06:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="qkM+vHPC" X-Original-To: linux-kernel@vger.kernel.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE1371D68D; Thu, 4 Jan 2024 06:50:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Sender:Reply-To:Cc:Content-ID:Content-Description; bh=AvGkACQcr2iyTESCDfvJI1c7IEOTfjYcidY62BG+hQg=; b=qkM+vHPC1kerwfZCfHWPncWot+ e///vE6FWI0lSMPj4VRdGerdJfi7HKBUFOJwOPff5cN+qRe+Fn/YuEG93UZ4JQ+A4YVZS57Ni6T54 9ZJA1/XdgGUd7wrdfUctO6XCNeLlKQbclDVZrcVAFAQ2oi/bkqv3gHt4lASRwM777msflH0KwE+o+ 7KfPSp1G+HHxzk3v3amcGwtRA9BHULgaSJMHQkZLJXH+ZyHWo7JS5tYGkw/7FBYYHpcMtAFoke20g ATaPARG2jQyKXNymq07iJ6l0GrKQqDzm4UmNIH/4saT5UGRDLprcKaKOTDCu7gqFRRajF9AIqs1Vm 3wJnNQaQ==; Received: from [50.53.46.231] (helo=[192.168.254.15]) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rLHZA-00D1HE-12; Thu, 04 Jan 2024 06:50:56 +0000 Message-ID: Date: Wed, 3 Jan 2024 22:50:55 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/4] kstrtox: introduce a safer version of memparse() Content-Language: en-US To: Qu Wenruo , Qu Wenruo , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, christophe.jaillet@wanadoo.fr, andriy.shevchenko@linux.intel.com, David.Laight@ACULAB.COM, ddiss@suse.de, geert@linux-m68k.org References: <4960b36916d55e22be08fe1689b81e0eefb47578.1704324320.git.wqu@suse.com> <248554b4-a549-4e94-835c-3430403b746c@infradead.org> From: Randy Dunlap In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 1/3/24 22:42, Qu Wenruo wrote: > > > On 2024/1/4 17:00, Randy Dunlap wrote: >> Hi, >> > [...] >>> + *        parameter. >>> + * >>> + * @suffixes:    The suffixes which should be parsed. Use logical ORed >>> + *        memparse_suffix enum to indicate the supported suffixes. >>> + *        The suffixes are case-insensive, all 2 ^ 10 based. >> >>                          case-insensitive >> >>> + *        Supported ones are "KMGPTE". >>> + *        NOTE: If one suffix out of the supported one is hit, it would >> >>                                                  ones >> >>> + *        end the parse normally, with @retptr pointed to the unsupported >>> + *        suffix. >> >> Could you explain (or give an example) of "to the unsupported suffix"? >> This isn't clear IMO. > > Oh, my bad, that sentence itself is not correct. > > What I really want to say is: > >  If one suffix (one of "KMGPTE") is hit but that suffix is not >  specified in the @suffxies parameter, it would end the parse normally, >  with @retptr pointed to the (unsupported) suffix. (corrected ^^^) > The example would be the "68k " case in the ok cases in the next patch. > We have two different cases for the same "68k" string, with different > @suffixes and different results: > >     "68k ", KMGPTE -> 68 * 1024, @retptr at " ". >     "68k ", M -> 68, @retptr at 'k'. > > I don't have a better expression here unfortunately, maybe the special > case is not even worthy explaining? > No, the corrected paragraph above is good. (s/would end/ends/) Except for one thing: the examples here terminate on a space character, but the function kernel-doc says "null-terminated": +/** + * memparse_safe - convert a string to an unsigned long long, safer version of + * memparse() + * + * @s: The start of the string. Must be null-terminated. >> >>> + * >>> + * @res:    Where to write the result. >>> + * >>> + * @retptr:    (output) Optional pointer to the next char after parse completes. >>> + * >>> + * Return 0 if any valid numberic string can be parsed, and @retptr updated. >>> + * Return -INVALID if no valid number string can be found. >>> + * Return -ERANGE if the number overflows. >>> + * For minus return values, @retptr would not be updated. >> >>   * Returns: >>   * * %0 if any valid numeric string can be parsed, and @retptr is updated. >>   * * %-EINVAL if no valid number string can be found. >>   * * %-ERANGE if the number overflows. >>   * * For negative return values, @retptr is not updated. >> >> >> For *ALL* of the comments, I request/suggest that you change the "would be" or >> "would not be" to "is" or "is not" or whatever present tense words make the >> most sense. > > No problem. -- #Randy