Re: [PATCH v2 2/2] mm: Covert sysfs input to bool using kstrtobool()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 12, 2022 at 06:05:37PM -0700, Andrew Morton wrote:
> On Wed, 27 Apr 2022 18:17:29 +0300 Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> 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:

	ret = f();
	if (ret)
		return ret;

is slightly better because it doesn't require to load EINVAL into
register:

	call f
	test	eax, eax
	js	1f
	...
1:
	ret




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux