staging: speakup: replace simple_strtoul with kstrtoul
PATCH 1/1 staging: speakup: replace simple_strtoul with kstrtoul
Replacing obsolete simple_strtoul with kstrtoul.
--- drivers/staging/speakup/varhandlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/speakup/varhandlers.c +1 -1
@@ -323,7 +323,7 @@ char *spk_s2uchar(char *start, char *dest) {int val =0 ; - val =simple_strtoul (skip_spaces (start), &start,10 ); + val =kstrtoul (skip_spaces (start), &start,10 );if (*start ==',' ) start++; *dest = (u_char )val;
Signature · 1 line
1.8.3.1
Quoted 2 lines · samuel kihahu
Replacing obsolete
simple_strtoulwith kstrtoul.
Nope. That's wrong. Learn how the functions are different beyond just the name.
regards,
dan carpenter
Quoted 6 lines · Dan Carpenter
Quoted 2 lines · samuel kihahu
Replacing obsolete
simple_strtoulwith kstrtoul.Nope. That's wrong. Learn how the functions are different beyond just the name.
Noted, have made corrections to fit the kstrtoul and handle the return value.
Quoted 1 line
From
71d2f7123e697b95371585b4af9a0b35262307eaMon Sep 17 00:00:00 2001
From: samuel kihahu <[email protected]>
Date: Wed, 17 Dec 2014 16:31:05 +0300
Subject: [PATCH] staging: speakup: replace simple_strtoul with kstrtoul
Replacing obsolete simple_strtoul with kstrtoul and checking the return status.
--- drivers/staging/speakup/varhandlers.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/speakup/varhandlers.c +3 -2
@@ -321,9 +321,10 @@ char *spk_strlwr(char *s)char *spk_s2uchar (char *start,char *dest) { -int val =0 ; +unsigned long val; - val =simple_strtoul (skip_spaces (start), &start,10 ); +if (kstrtoul (skip_spaces (start), &start, val)) +return -EINVAL ;if (*start ==',' ) start++; *dest = (u_char )val;
Signature · 1 line
1.8.3.1
Quoted 9 lines · samuel kihahu
Quoted 6 lines · Dan Carpenter
Quoted 2 lines · samuel kihahu
Replacing obsolete
simple_strtoulwith kstrtoul.Nope. That's wrong. Learn how the functions are different beyond just the name.
Noted, have made corrections to fit the kstrtoul and handle the return value.
You have to compile test these things. Really kernel programming is not a good way to learn how to program. :(
regards,
dan carpenter
Quoted 8 lines · Dan Carpenter
Quoted 7 lines · samuel kihahu
Quoted 6 lines · Dan Carpenter
Quoted 2 lines · samuel kihahu
Replacing obsolete
simple_strtoulwith kstrtoul.Nope. That's wrong. Learn how the functions are different beyond just the name.
Quoted 9 lines
Quoted 2 lines
Noted, have made corrections to fit the kstrtoul and handle the return value.
You have to compile test these things. Really kernel programming is not a good way to learn how to program. :(
regards,
dan carpenter
Appreciate the feedback, have modified the patch, tested and confirmed it builds.
Quoted 1 line
From
3d39fd533b4a75e567f76f07f5bc978adddb0721Mon Sep 17 00:00:00 2001
From: samuel kihahu <[email protected]>
Date: Thu, 18 Dec 2014 17:42:37 +0300
Subject: [PATCH] staging: speakup: replace simple_strtoul with kstrtoul
Replacing obsolete simple_strtoul with kstrtoul, checking and returning the correct error code.
--- drivers/staging/speakup/varhandlers.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/staging/speakup/varhandlers.c +6 -2
@@ -321,9 +321,13 @@ char *spk_strlwr(char *s)char *spk_s2uchar (char *start,char *dest) { -int val =0 ; +unsigned long val; +int ret; + + ret =kstrtoul (skip_spaces (start),10 , &val); +if (IS_ERR (&ret)) +return ERR_CAST (&ret); - val =simple_strtoul (skip_spaces (start), &start,10 );if (*start ==',' ) start++; *dest = (u_char )val;
Signature · 1 line
1.8.3.1
Quoted 15 lines · samuel kihahu
Quoted 14 lines · Dan Carpenter
Quoted 9 lines · samuel kihahu
Quoted 6 lines · Dan Carpenter
Quoted 2 lines · samuel kihahu
Replacing obsolete
simple_strtoulwith kstrtoul.Nope. That's wrong. Learn how the functions are different beyond just the name.
Noted, have made corrections to fit the kstrtoul and handle the return value.
You have to compile test these things. Really kernel programming is not a good way to learn how to program. :(
Quoted 6 lines
Quoted 3 lines
regards,
dan carpenterAppreciate the feedback, have modified the patch, tested and confirmed it builds.
No. It's still really wrong. One of the key differences between kstrtoul() and simple_strtoul() is that simple_strtoul() gives you a pointer to the end of the string.
It's actually best to use simple_strtoul() here. Checkpatch.pl is wrong.
As well the new error handling doesn't work at all.
regards,
dan carpenter