* [PATCH 1/1] fs/ncpfs/getopt.c: replace simple_strtoul by kstrtoul
@ 2014-05-23 20:26 Fabian Frederick
2014-05-29 22:21 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Fabian Frederick @ 2014-05-23 20:26 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, Petr Vandrovec
Remove obsolete simple_strtoul in ncp_getopt
This is untested.
Cc: Petr Vandrovec <petr@vandrovec.name>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
fs/ncpfs/getopt.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/fs/ncpfs/getopt.c b/fs/ncpfs/getopt.c
index 03ffde1..344889c 100644
--- 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;
}
- 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] fs/ncpfs/getopt.c: replace simple_strtoul by kstrtoul
2014-05-23 20:26 [PATCH 1/1] fs/ncpfs/getopt.c: replace simple_strtoul by kstrtoul Fabian Frederick
@ 2014-05-29 22:21 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2014-05-29 22:21 UTC (permalink / raw)
To: Fabian Frederick; +Cc: linux-kernel, Petr Vandrovec
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-29 22:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-23 20:26 [PATCH 1/1] fs/ncpfs/getopt.c: replace simple_strtoul by kstrtoul Fabian Frederick
2014-05-29 22:21 ` Andrew Morton
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®