staging: speakup: Replace simple_strtoul by kstrtoul
PATCH 1/1 staging: speakup: Replace simple_strtoul by kstrtoul
simple_strtoul is obsolete and hence has been replaced by kstrtoul as mentioned by checkpatch.pl
--- drivers/staging/speakup/kobjects.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/speakup/kobjects.c +4 -2
@@ -126,6 +126,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,int do_characters = !strcmp (attr->attr.name,"characters" );size_t desc_length =0 ;int i; +int err;spin_lock_irqsave (&speakup_info.spinlock, flags);while (cp < end) {
@@ -153,7 +154,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,continue ; } - index =simple_strtoul (cp, &temp,10 ); + err =kstrtoul (cp,10 , &index);if (index >255 ) { rejected++; cp = linefeed +1 ;
@@ -757,6 +758,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 +785,7 @@ static ssize_t message_store_helper(const char *buf, size_t count,continue ; } - index =simple_strtoul (cp, &temp,10 ); + err =kstrtoul (cp,10 , &index);while ((temp < linefeed) && (*temp ==' ' || *temp =='\t' )) temp++;
Signature · 1 line
2.9.2
Quoted 2 lines · Gargi Sharma
simple_strtoulis obsolete and hence has been replaced by kstrtoul as mentioned by checkpatch.pl
To my recollection, the transformation from one to the other is not so simple, and is sometimes not possible. Could you explain in more detail why what you have done is correct? At least the second case looks like it cannot be, because your transformed code doesn't initialize temp any more, and it is used a couple lines after the call site.
julia
Quoted 54 lines
Signed-off-by Gargi Sharma <[email protected]>--- drivers/staging/speakup/kobjects.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/staging/speakup/kobjects.c +4
-3@@ -126,6 +126,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,int do_characters = !strcmp (attr->attr.name,"characters" );size_t desc_length =0 ;int i; +int err;spin_lock_irqsave (&speakup_info.spinlock, flags);while (cp < end) {@@ -153,7 +154,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,continue ; } - index =simple_strtoul (cp, &temp,10 ); + err =kstrtoul (cp,10 , &index);if (index >255 ) { rejected++; cp = linefeed +1 ;@@ -757,6 +758,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 +785,7 @@ static ssize_t message_store_helper(const char *buf, size_t count,continue ; } - index =simple_strtoul (cp, &temp,10 ); + err =kstrtoul (cp,10 , &index);while ((temp < linefeed) && (*temp ==' ' || *temp =='\t' )) temp++; --2.9.2
--
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/20160912205044.26537-1-gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Samuel Thibault
Hello,
Quoted 2 lines · Gargi Sharma, on Tue 13 Sep 2016 02:20:44 +0530, wrote:
simple_strtoulis obsolete and hence has been replaced by kstrtoul as mentioned by checkpatch.plPlease note the details.
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/staging/speakup/kobjects.c
Quoted 4 lines
drivers/staging/speakup/kobjects.c static ssize_t chars_chartab_store(struct kobject
Quoted 4 lines
index 528cbdc..884b2eb 100644
drivers/staging/speakup/kobjects.c +0
-0@@ -126,6 +126,7 @@ static ssize_t chars_chartab_store(struct kobject
*kobj,
Quoted 8 lines
drivers/staging/speakup/kobjects.c static ssize_t chars_chartab_store(struct kobject
Quoted 8 lines
drivers/staging/speakup/kobjects.c +1
-0int do_characters = !strcmp (attr->attr.name,"characters" );size_t desc_length =0 ;int i; +int err;spin_lock_irqsave (&speakup_info.spinlock, flags);while (cp < end) {@@ -153,7 +154,7 @@ static ssize_t chars_chartab_store(struct kobject
*kobj,
Quoted 10 lines
drivers/staging/speakup/kobjects.c static ssize_t chars_chartab_store(struct kobject *kobj, · line 160
Quoted 8 lines
drivers/staging/speakup/kobjects.c +1
-1continue ; } - index =simple_strtoul (cp, &temp,10 ); + err =kstrtoul (cp,10 , &index);if (index >255 ) { rejected++; cp = linefeed +1 ;Here it would be good to include err in the if test, so as to properly
reject
Quoted 1 line
non-numeric values.
temp is used here as well and again is not updated. So, I think kstrtoul can't be used here as well,
thanks,
gargi