staging: speakup: Replace simple_strtoul with kstrtoul
PATCH 1/1 staging: speakup: Replace simple_strtoul with kstrtoul
Replace obsolete simple_strtoul with kstrtoul.
The Coccinelle semantic patch used to make this change is as follows:
// <smpl>
@@
unsigned long l;
expression e,f,g;
@@
- l = simple_strtoul(e, &f, g)
+ kstrtoul(e, g, &l)
// </smpl>
Additionally, since kstrtoul returns 0 on success and an error code on failure introduced err variable to store and return the error code. This change was made by hand.
--- drivers/staging/speakup/kobjects.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/staging/speakup/kobjects.c +8 -3
@@ -125,7 +125,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,int reset =0 ;int do_characters = !strcmp (attr->attr.name,"characters" );size_t desc_length =0 ; -int i; +int i, err;spin_lock_irqsave (&speakup_info.spinlock, flags);while (cp < end) {
@@ -153,7 +153,9 @@ static ssize_t chars_chartab_store(struct kobject *kobj,continue ; } - index =simple_strtoul (cp, &temp,10 ); + err =kstrtoul (cp,10 , &index); +if (err) +return err;if (index >255 ) { rejected++; cp = linefeed +1 ;
@@ -757,6 +759,7 @@ static ssize_t message_store_helper(const char *buf, size_t count,enum msg_index_t firstmessage = group->start;enum msg_index_t lastmessage = group->end;enum msg_index_t curmessage; +int err;while (cp < end) {
@@ -783,7 +786,9 @@ static ssize_t message_store_helper(const char *buf, size_t count,continue ; } - index =simple_strtoul (cp, &temp,10 ); + err =kstrtoul (cp,10 , &index); +if (err) +return err;while ((temp < linefeed) && (*temp ==' ' || *temp =='\t' )) temp++;
Signature · 1 line
1.9.1
Quoted 2 lines · Amitoj Kaur Chawla
Replace obsolete
simple_strtoulwith kstrtoul.
The Coccinelle semantic patch used to make this change is as follows:
Check on the use of temp. In teh second case it is used after the call. I believe that the call is supposed to update the pointer, but you can check on that.
julia
Quoted 71 lines
// <smpl>
@@
unsigned long l;
expression e,f,g;
@@
- l =simple_strtoul(e, &f, g)
+kstrtoul(e, g, &l)
// </smpl>Additionally, since kstrtoul returns 0 on success and an error code on failure introduced
errvariable to store and return the error code. This change was made by hand.Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/staging/speakup/kobjects.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/staging/speakup/kobjects.c +8
-4@@ -125,7 +125,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,int reset =0 ;int do_characters = !strcmp (attr->attr.name,"characters" );size_t desc_length =0 ; -int i; +int i, err;spin_lock_irqsave (&speakup_info.spinlock, flags);while (cp < end) {@@ -153,7 +153,9 @@ static ssize_t chars_chartab_store(struct kobject *kobj,continue ; } - index =simple_strtoul (cp, &temp,10 ); + err =kstrtoul (cp,10 , &index); +if (err) +return err;if (index >255 ) { rejected++; cp = linefeed +1 ;@@ -757,6 +759,7 @@ static ssize_t message_store_helper(const char *buf, size_t count,enum msg_index_t firstmessage = group->start;enum msg_index_t lastmessage = group->end;enum msg_index_t curmessage; +int err;while (cp < end) {@@ -783,7 +786,9 @@ static ssize_t message_store_helper(const char *buf, size_t count,continue ; } - index =simple_strtoul (cp, &temp,10 ); + err =kstrtoul (cp,10 , &index); +if (err) +return err;while ((temp < linefeed) && (*temp ==' ' || *temp =='\t' )) temp++; --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/20160222121811.GA21856%40amitoj-Inspiron-3542.
For more options, visit https://groups.google.com/d/optout.
Quoted 4 lines · Julia Lawall
On Mon, 22 Feb 2016, Amitoj Kaur Chawla wrote:
Quoted 9 lines
Quoted 2 lines
Replace obsolete
simple_strtoulwith kstrtoul.
The Coccinelle semantic patch used to make this change is as follows:Check on the use of temp. In teh second case it is used after the call. I believe that the call is supposed to update the pointer, but you can check on that.
julia
Checked. I think I'll have to revise the semantic patch to only look for cases which have a NULL pointer as the middle argument since otherwise I'm not updating the pointer with this change.
But that makes me wonder about the checkpatch warning for this, since simple_strtoul is obsolete and should be replaced.
Amitoj
Quoted 15 lines · Amitoj Kaur Chawla
Quoted 4 lines · Julia Lawall
On Mon, 22 Feb 2016, Amitoj Kaur Chawla wrote:
Quoted 9 lines
Quoted 2 lines
Replace obsolete
simple_strtoulwith kstrtoul.
The Coccinelle semantic patch used to make this change is as follows:Check on the use of temp. In teh second case it is used after the call. I believe that the call is supposed to update the pointer, but you can check on that.
julia
Quoted 6 lines
Checked. I think I'll have to revise the semantic patch to only look for cases which have a NULL pointer as the middle argument since otherwise I'm not updating the pointer with this change.
But that makes me wonder about the checkpatch warning for this, since
simple_strtoulis obsolete and should be replaced.
Yes... The warning tends to lead people to do things that are wrong.
julia