public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: JJ Ding <jj_ding@emc.com.tw>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
	JJ Ding <dgdunix@gmail.com>
Subject: Re: [PATCH v2] Input: convert obsolete strict_strtox to kstrtox
Date: Tue, 08 Nov 2011 16:47:25 +0800	[thread overview]
Message-ID: <87sjlz80gy.fsf@emc.com.tw> (raw)
In-Reply-To: <87vcqv838n.fsf@emc.com.tw>

On Tue, 08 Nov 2011 15:47:36 +0800, JJ Ding <jj_ding@emc.com.tw> wrote:
> On Mon, 7 Nov 2011 22:28:01 -0800, Dmitry Torokhov <dmitry.torokhov@gmail.com> 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

  reply	other threads:[~2011-11-08  8:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-07 11:54 [PATCH v2] Input: convert obsolete strict_strtox to kstrtox JJ Ding
2011-11-08  3:59 ` Dmitry Torokhov
2011-11-08  6:28   ` Dmitry Torokhov
2011-11-08  7:47     ` JJ Ding
2011-11-08  8:47       ` JJ Ding [this message]
2011-11-08 18:41         ` Dmitry Torokhov
2011-11-08 21:33           ` Jonathan Cameron

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=87sjlz80gy.fsf@emc.com.tw \
    --to=jj_ding@emc.com.tw \
    --cc=dgdunix@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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