linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Jagdish Gediya <jvgediya@linux.ibm.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Jonathan.Cameron@huawei.com, adobriyan@gmail.com,
	rf@opensource.cirrus.com, pmladek@suse.com, ying.huang@intel.com,
	dave.hansen@intel.com
Subject: Re: [PATCH v2 2/2] mm: Covert sysfs input to bool using kstrtobool()
Date: Thu, 12 May 2022 18:05:37 -0700	[thread overview]
Message-ID: <20220512180537.5296f39b27c3488080ff67cf@linux-foundation.org> (raw)
In-Reply-To: <YmleidxlL2/d859f@smile.fi.intel.com>

On Wed, 27 Apr 2022 18:17:29 +0300 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Tue, Apr 26, 2022 at 10:30:40PM +0530, Jagdish Gediya wrote:
> > Sysfs input conversion to corrosponding bool value e.g. "false" or "0"
> > to false, "true" or "1" to true are currently handled through strncmp
> > at multiple places. Use kstrtobool() to convert sysfs input to bool
> > value.
> 
> ...
> 
> > +	if (kstrtobool(buf, &numa_demotion_enabled))
> >  		return -EINVAL;
> 
> Hmm... The commit message doesn't explain what's wrong with the error codes
> returned by kstrtobool(). Can't it be
> 
> 	ret = kstrtobool();
> 	if (ret)
> 		return ret;
> 
> ?

Jagdish fell asleep.

Yes, I agree.  It has no practical difference at present because
kstrtobool() can only return 0 or -EINVAL.  I did this:

--- a/mm/migrate.c~mm-convert-sysfs-input-to-bool-using-kstrtobool-fix
+++ a/mm/migrate.c
@@ -2523,8 +2523,10 @@ static ssize_t numa_demotion_enabled_sto
 					   struct kobj_attribute *attr,
 					   const char *buf, size_t count)
 {
-	if (kstrtobool(buf, &numa_demotion_enabled))
-		return -EINVAL;
+	ssize_t ret;
+
+	ret = kstrtobool(buf, &numa_demotion_enabled);
+		return ret;
 
 	return count;
 }
--- a/mm/swap_state.c~mm-convert-sysfs-input-to-bool-using-kstrtobool-fix
+++ a/mm/swap_state.c
@@ -874,8 +874,11 @@ static ssize_t vma_ra_enabled_store(stru
 				      struct kobj_attribute *attr,
 				      const char *buf, size_t count)
 {
-	if (kstrtobool(buf, &enable_vma_readahead))
-		return -EINVAL;
+	ssize_t ret;
+
+	ret = kstrtobool(buf, &enable_vma_readahead);
+	if (ret)
+		return ret;
 
 	return count;
 }
_



  reply	other threads:[~2022-05-13  1:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26 17:00 [PATCH v2 1/2] lib/kstrtox.c: Add "false"/"true" support to kstrtobool() Jagdish Gediya
2022-04-26 17:00 ` [PATCH v2 2/2] mm: Covert sysfs input to bool using kstrtobool() Jagdish Gediya
2022-04-26 17:24   ` Matthew Wilcox
2022-04-27 15:17   ` Andy Shevchenko
2022-05-13  1:05     ` Andrew Morton [this message]
2022-05-13 18:28       ` Alexey Dobriyan
2022-05-16 10:48       ` Jagdish Gediya
2022-05-16 10:47     ` Jagdish Gediya
2022-04-26 17:23 ` [PATCH v2 1/2] lib/kstrtox.c: Add "false"/"true" support to kstrtobool() Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220512180537.5296f39b27c3488080ff67cf@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=adobriyan@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dave.hansen@intel.com \
    --cc=jvgediya@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pmladek@suse.com \
    --cc=rf@opensource.cirrus.com \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).