From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80C09C43334 for ; Mon, 25 Jul 2022 14:55:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3C578E0002; Mon, 25 Jul 2022 10:55:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DEC348E0001; Mon, 25 Jul 2022 10:55:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB4048E0002; Mon, 25 Jul 2022 10:55:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B93258E0001 for ; Mon, 25 Jul 2022 10:55:38 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 86CA61404D2 for ; Mon, 25 Jul 2022 14:55:38 +0000 (UTC) X-FDA: 79725921156.14.F55FF46 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id DE1C01800A8 for ; Mon, 25 Jul 2022 14:55:36 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 689B82B; Mon, 25 Jul 2022 07:55:36 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.28.151]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1F5DB3F73D; Mon, 25 Jul 2022 07:55:34 -0700 (PDT) Date: Mon, 25 Jul 2022 15:55:27 +0100 From: Mark Rutland To: Jagdish Gediya Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, ying.huang@intel.com, dave.hansen@intel.com, Jonathan.Cameron@huawei.com, adobriyan@gmail.com, akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, rf@opensource.cirrus.com, pmladek@suse.com, will@kernel.org Subject: Re: [PATCH v3 1/2] lib/kstrtox.c: Add "false"/"true" support to kstrtobool() Message-ID: References: <20220426180203.70782-1-jvgediya@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220426180203.70782-1-jvgediya@linux.ibm.com> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658760938; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o54nsGtYcG5ZZLVFBo6pOUqFGi3wEFhUcFX3+F3Zov0=; b=xhV+ynQ1Y0TjbtKcPF4zygUseF2YcDZwW+Zec6rlNbOVMLXwZtd9yZFistOWbF2oH8jJrN ERUM2eoCdqWWl88EEjXAz63h2pDPFPRYcDwC+TLAVvXKWylr2FeKfAM3mh6Sgfn9KA49qR 1IbDQX7hT1Tw3uKWL+9LFOjqCIjXabY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658760938; a=rsa-sha256; cv=none; b=BpeYxeoMjAK6gg0JJCUUWbnARTYranEn2p+yg97eF4VsaG44DLykxSDLzIYYNtmv6Y/4Tc h1+RXZAgVg7D16DSSXyO8yUZcQd7hFdo2BCvzlOmU0ttVeUh7ej3VqfAn3lOH3Hquyv9YU nqi6VmuuERfM2zOk5TQcveFmebItRvE= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of mark.rutland@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=mark.rutland@arm.com; dmarc=pass (policy=none) header.from=arm.com Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of mark.rutland@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=mark.rutland@arm.com; dmarc=pass (policy=none) header.from=arm.com X-Rspam-User: X-Rspamd-Queue-Id: DE1C01800A8 X-Rspamd-Server: rspam05 X-Stat-Signature: x9be8xqfrohemkqixr4sgs37kq5p3fct X-HE-Tag: 1658760936-333166 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Apr 26, 2022 at 11:32:02PM +0530, Jagdish Gediya wrote: > At many places in kernel, It is necessary to convert sysfs input > to corrosponding bool value e.g. "false" or "0" need to be converted > to bool false, "true" or "1" need to be converted to bool true, > places where such conversion is needed currently check the input > string manually, kstrtobool() can be utilized at such places but > currently it doesn't have support to accept "false"/"true". > > Add support to accept "false"/"true" as valid string in kstrtobool(). > > Signed-off-by: Jagdish Gediya > Reviewed-by: Matthew Wilcox (Oracle) I've just spotted that this broke arm64's "rodata=full" command line option, since "full" gets parsed as 'f' = FALSE, when previously that would have been rejected. So anyone passing "rodata=full" on the command line will have rodata disabled, which is not what they wanted. The current state of things is a bit messy (we prase the option twice because arch code needs it early), and we can probably fix that with some refactoring, but I do wonder if we actually want to open up the sysfs parsing to accept anything *beginning* with [tTfF] rather than the full "true" and "false" strings as previously, or whether it's worth reverting this for now in case anything else is affected. Mark. > --- > Chnages in v2: > - kstrtobool to kstrtobool() in commit message. > - Split single patch into 2 > - Remove strcmp usage from kstrtobool() and instead compare 1st > character only. > > Changes in v3: > - Covert -> Convert in patch 2 subject > - Collected Reviewed-by: Matthew Wilcox (Oracle) > > lib/kstrtox.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/lib/kstrtox.c b/lib/kstrtox.c > index 886510d248e5..465e31e4d70d 100644 > --- a/lib/kstrtox.c > +++ b/lib/kstrtox.c > @@ -340,7 +340,7 @@ EXPORT_SYMBOL(kstrtos8); > * @s: input string > * @res: result > * > - * This routine returns 0 iff the first character is one of 'Yy1Nn0', or > + * This routine returns 0 if the first character is one of 'YyTt1NnFf0', or > * [oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL. Value > * pointed to by res is updated upon finding a match. > */ > @@ -353,11 +353,15 @@ int kstrtobool(const char *s, bool *res) > switch (s[0]) { > case 'y': > case 'Y': > + case 't': > + case 'T': > case '1': > *res = true; > return 0; > case 'n': > case 'N': > + case 'f': > + case 'F': > case '0': > *res = false; > return 0; > -- > 2.35.1 > >