Staging: speakup: Replace simple_strtoul with kstroul
PATCH 1/1 Staging: speakup: Replace simple_strtoul with kstroul
Addresses checkpatch.pl warning:
WARNING: simple_strtoul is obsolete, use kstroul instead
Makes the indicated replacement
--- drivers/staging/speakup/varhandlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/speakup/varhandlers.c +1 -1
@@ -324,7 +324,7 @@ char *spk_s2uchar(char *start, char *dest) {int val =0 ; - val =simple_strtoul (skip_spaces (start), &start,10 ); + val =kstroul (skip_spaces (start), &start,10 );if (*start ==',' ) start++; *dest = (u_char )val;
Signature · 1 line
1.9.1
Quoted 2 lines · Katie Dunne
Addresses checkpatch.pl warning:
WARNING:simple_strtoulis obsolete, use kstroul instead
There is no such function. There is a function kstrtoul, but it doesn't take the same set of arguments, and you have to argue carefully that the transformed code has the same semantics.
Your code should not have compiled. If you think that you compiled it, check whether you have a .o file for your .c file. If not, then you need to adjust your configuration to be sure to be compiling this code.
julia
Quoted 31 lines
Makes the indicated replacement
Signed-off-by Katie Dunne <[email protected]>--- drivers/staging/speakup/varhandlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/speakup/varhandlers.c +1
-2@@ -324,7 +324,7 @@ char *spk_s2uchar(char *start, char *dest) {int val =0 ; - val =simple_strtoul (skip_spaces (start), &start,10 ); + val =kstroul (skip_spaces (start), &start,10 );if (*start ==',' ) start++; *dest = (u_char )val; --1.9.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20150223160750.GA3917%40katie-Inspiron-5748.
For more options, visit https://groups.google.com/d/optout.
RFC v2 1/1 Staging: speakup: Replace simple_strtoul with kstrtoul
When compiling the following patch I get two warnings:
WARNING: return makes pointer from integer without a cast return -EINVAL;
^
WARNING: Cast from pointer to integer of different size
*dest = (u_char)res;
^I'd appreciate any feedback you can give me.
Addresses checkpatch.pl warning:
WARNING: simple_strtoul is obsolete, use kstrtoul instead
Makes indicated change
---
Changes in v2:
-updates arguments for kstrtoul
-checks return for parsing error
--- drivers/staging/speakup/varhandlers.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/staging/speakup/varhandlers.c +5 -2
@@ -323,10 +323,13 @@ char *spk_strlwr(char *s)char *spk_s2uchar (char *start,char *dest) {int val =0 ; +unsigned long *res =0UL ; - val =kstroul (skip_spaces (start), &start,10 ); + val =kstrtoul (skip_spaces (start),10 , res); +if (val) +return -EINVAL ;if (*start ==',' ) start++; - *dest = (u_char )val; + *dest = (u_char )res;return start; }
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [RFC v2] Staging: speakup: Replace simple_strtoul with kstrtoul
Quoted 5 lines · Katie Dunne
When compiling the following patch I get two warnings:
WARNING: return makes pointer from integer without a cast return
-EINVAL;
^
You have two return statements. One says return -EINVAL and one says return start. Start is a pointer. -EINVAL is an integer. If a function wants to return an integer from a pointer-typed function, it can use ERR_PTR(-EINVAL).
On the other hand, that would just make the types work out. It seems that you are significantly changing the semantics of the function. For example, the caller does not currently expect an error value. Removing simple_strtoul is often very complicated. You need to consider several cases:
What does it do on a string that contains only an unsigned long? What does it do on a string that contains an unsigned long followed by something else?
What does it do on a string that contains something else entirely?
You will see that kstrtoul does not have exactly the same behavior on these three cases. So then you have to adjust this function so that the effect is the same.
Quoted 3 lines
WARNING: Cast from pointer to integer of different size
*dest = (u_char)res; ^
Res is a pointer to unsigned long, thus probably 32 or 64 bits. u_char is only 8 bits, and not a pointer. Perhaps throwing away all the bits is not what is intended.
drivers/staging/speakup/varhandlers.c char *spk_strlwr(char *s) · line 328
Quoted 3 lines
drivers/staging/speakup/varhandlers.c +1
-1- val =kstroul (skip_spaces (start), &start,10 ); + val =kstrtoul (skip_spaces (start),10 , res);
Note that this is a patch against your previous change rather than against the original code. Even when you just want feedback, it would be good to provide the original code so that one could understand the change in the proper context.
julia
Quoted 18 lines
drivers/staging/speakup/varhandlers.c +3
-2+if (val) +return -EINVAL ;if (*start ==',' ) start++; - *dest = (u_char )val; + *dest = (u_char )res;return start; } --1.9.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20150224155911.GA31347%40katie-Inspiron-5748.
For more options, visit https://groups.google.com/d/optout.