mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Fabian Frederick <fabf@skynet.be>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Petr Vandrovec <petr@vandrovec.name>
Subject: Re: [PATCH 1/1] fs/ncpfs/getopt.c: replace simple_strtoul by kstrtoul
Date: Thu, 29 May 2014 15:21:53 -0700	[thread overview]
Message-ID: <20140529152153.5387970fd21c7add9837cfe3@linux-foundation.org> (raw)
In-Reply-To: <20140523222611.862216f7570633a5bf0f0e89@skynet.be>

On Fri, 23 May 2014 22:26:11 +0200 Fabian Frederick <fabf@skynet.be> wrote:

> Remove obsolete simple_strtoul in ncp_getopt

Looks good to me.

> 
> --- a/fs/ncpfs/getopt.c
> +++ b/fs/ncpfs/getopt.c
> @@ -53,15 +53,14 @@ int ncp_getopt(const char *caller, char **options, const struct ncp_option *opts
>  				return -EINVAL;
>  			}
>  			if (opts->has_arg & OPT_INT) {
> -				char* v;
> +				int rc = kstrtoul(val, 0, value);
>  
> -				*value = simple_strtoul(val, &v, 0);
> -				if (!*v) {
> -					return opts->val;
> +				if (rc) {
> +					pr_info("%s: invalid numeric value in %s=%s\n",
> +						caller, token, val);
> +					return rc;

Because kstrtoul("42foo", ...) returns -EINVAL rather than 42.  This
behaviour isn't obvious - I had to dive into the implementation to work
it out.  We forgot to document what kstrtoul() considers a "parsing
error".


>  				}
> -				pr_info("%s: invalid numeric value in %s=%s\n",
> -					caller, token, val);
> -				return -EDOM;
> +				return opts->val;
>  			}
>  			if (opts->has_arg & OPT_STRING) {
>  				return opts->val;
> -- 
> 1.9.1

      reply	other threads:[~2014-05-29 22:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23 20:26 Fabian Frederick
2014-05-29 22:21 ` Andrew Morton [this message]

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=20140529152153.5387970fd21c7add9837cfe3@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=fabf@skynet.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=petr@vandrovec.name \
    /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

all inboxes | Powered by JetHome®