Re: [PATCH v2] Input: convert obsolete strict_strtox to kstrtox

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

 



On Tue, 08 Nov 2011 15:47:36 +0800, JJ Ding <jj_ding@xxxxxxxxxx> wrote:
> On Mon, 7 Nov 2011 22:28:01 -0800, Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx> wrote:
> > On Mon, Nov 07, 2011 at 07:59:30PM -0800, Dmitry Torokhov wrote:
> > > 
> > > Applied, thanks JJ.
> > > 
> > 
> > Sorry, I take it back...
> > 
> > > -       if (strict_strtoul(buf, 10, &value) || value > 1)
> > > +       if (kstrtouint(buf, 10, &value) || value > 1)
> > >                 return -EINVAL;
> > 
> > This mangles error condition from kstrtouint and reporting conditions
> > beside -EINVAL was the reason for introducing new API IIRC. The proper
> > conversion should be:
> > 
> > 	err = kstrtouint(buf, 10, &value);
> > 	if (err)
> > 		return err;
> > 
> > 	if (value > 1)
> > 		return -EINVAL;
> > 
> > Thanks.
> > 
> 
> Thanks, I get it. I'll fix and resend.
> 
> jj
> 

Thinking a bit more about your suggestion, and looking at the code more
closely, some uses of these conversions really want a u8, and some want a
bool. I think I should check the data type where these converted values
are really used, and use a more appropriate kstrtox.

And for those that just need a bool, do you think using strtobool
introduced in commit d0f1fed29e6e73d9d17f4c91a5896a4ce3938d45 OK?
That way the user may even type [NnYy01].

What do you think about the approach above?

Thanks,
jj

> > -- 
> > Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux