All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul
@ 2016-09-12 20:50 Gargi Sharma
       [not found] ` <20160912205630.GG5245@var.home>
  0 siblings, 1 reply; 7+ messages in thread
From: Gargi Sharma @ 2016-09-12 20:50 UTC (permalink / raw)
  To: outreachy-kernel
  Cc: w.d.hubbs, chris, kirk, samuel.thibault, gregkh, Gargi Sharma

simple_strtoul is obsolete and hence has been replaced by kstrtoul as
mentioned by checkpatch.pl

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
 drivers/staging/speakup/kobjects.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
index 528cbdc..884b2eb 100644
--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul
       [not found] ` <20160912205630.GG5245@var.home>
@ 2016-09-13  6:32   ` Gargi Sharma
  0 siblings, 0 replies; 7+ messages in thread
From: Gargi Sharma @ 2016-09-13  6:32 UTC (permalink / raw)
  To: Samuel Thibault
  Cc: outreachy-kernel, William Hubbs, Christopher Brannon, kirk,
	gregkh

[-- Attachment #1: Type: text/plain, Size: 1411 bytes --]

On Tue, Sep 13, 2016 at 2:26 AM, Samuel Thibault <
samuel.thibault@ens-lyon.org> wrote:
>
> Hello,
>
> Gargi Sharma, on Tue 13 Sep 2016 02:20:44 +0530, wrote:
> > simple_strtoul is obsolete and hence has been replaced by kstrtoul as
> > mentioned by checkpatch.pl
>
> Please note the details.
>
> > diff --git a/drivers/staging/speakup/kobjects.c
b/drivers/staging/speakup/kobjects.c
> > index 528cbdc..884b2eb 100644
> > --- a/drivers/staging/speakup/kobjects.c
> > +++ b/drivers/staging/speakup/kobjects.c
> > @@ -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;
>
> Here it would be good to include err in the if test, so as to properly
reject
> 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

[-- Attachment #2: Type: text/html, Size: 1979 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul
@ 2017-04-27 16:52 Shekhar Bhandakkar
  2017-04-27 21:58 ` Samuel Thibault
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Shekhar Bhandakkar @ 2017-04-27 16:52 UTC (permalink / raw)
  To: kernel-janitors

The simple_strtoul function is obsolete.
This patch replaces it by kstrtoul.

Signed-off-by: Shekhar Bhandakkar <cs14btech11006@iith.ac.in>
---
 drivers/staging/speakup/kobjects.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
index ca85476..8b9ddb9 100644
--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -127,6 +127,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,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;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul
  2017-04-27 16:52 [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul Shekhar Bhandakkar
@ 2017-04-27 21:58 ` Samuel Thibault
  2017-04-28  3:50 ` Shekhar Bhandakkar
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Samuel Thibault @ 2017-04-27 21:58 UTC (permalink / raw)
  To: kernel-janitors

Shekhar Bhandakkar, on jeu. 27 avril 2017 22:10:32 +0530, wrote:
> The simple_strtoul function is obsolete.
> This patch replaces it by kstrtoul.

> @@ -153,7 +154,9 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
>  			continue;
>  		}
>  
> -		index = simple_strtoul(cp, &temp, 10);
> +		err = kstrtoul(cp, 10, &index);

Again, that doesn't update the temp pointer, which is used below.
So really NACK from me.

Samuel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul
  2017-04-27 16:52 [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul Shekhar Bhandakkar
  2017-04-27 21:58 ` Samuel Thibault
@ 2017-04-28  3:50 ` Shekhar Bhandakkar
  2017-04-28  5:26 ` Julia Lawall
  2017-05-22 14:57 ` Dan Carpenter
  3 siblings, 0 replies; 7+ messages in thread
From: Shekhar Bhandakkar @ 2017-04-28  3:50 UTC (permalink / raw)
  To: kernel-janitors

The simple_strtoul function is obsolete.
This patch replaces it with kstrtoul.

Signed-off-by: Shekhar Bhandakkar <cs14btech11006@iith.ac.in>
---
 drivers/staging/speakup/kobjects.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
index ca85476..8a1ebe6 100644
--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -127,6 +127,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,10 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
 			continue;
 		}
 
-		index = simple_strtoul(cp, &temp, 10);
+		temp = cp;
+		err = kstrtoul(temp, 10, &index);
+		if (err)
+			return err;
 		if (index > 255) {
 			rejected++;
 			cp = linefeed + 1;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul
  2017-04-27 16:52 [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul Shekhar Bhandakkar
  2017-04-27 21:58 ` Samuel Thibault
  2017-04-28  3:50 ` Shekhar Bhandakkar
@ 2017-04-28  5:26 ` Julia Lawall
  2017-05-22 14:57 ` Dan Carpenter
  3 siblings, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2017-04-28  5:26 UTC (permalink / raw)
  To: kernel-janitors



On Fri, 28 Apr 2017, Shekhar Bhandakkar wrote:

> The simple_strtoul function is obsolete.
> This patch replaces it with kstrtoul.
>
> Signed-off-by: Shekhar Bhandakkar <cs14btech11006@iith.ac.in>
> ---
>  drivers/staging/speakup/kobjects.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
> index ca85476..8a1ebe6 100644
> --- a/drivers/staging/speakup/kobjects.c
> +++ b/drivers/staging/speakup/kobjects.c
> @@ -127,6 +127,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,10 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
>  			continue;
>  		}
>
> -		index = simple_strtoul(cp, &temp, 10);
> +		temp = cp;
> +		err = kstrtoul(temp, 10, &index);

I haven't looked at how temp is used, but I doubt that this is the
correct fix, because it doesn't make the distinction between cp and temp
meaningful.  In my experience, all of the remaining uses of
simple_strtoul cannot be converted to kstrtoul because they use the second
argument of simple_strtoul in some important way.  The checkpatch warning
is more intended to suggest that people avoid adding new uses of
simple_strtoul rather than an indication that it is possible to convert
all the old ones.

In any case, when you make a change in a patch, it should becomes [PATCH
v2] and under the --- you should explain what is new in the v2.  In a case
like this where the change is complex, above the --- you should also
explain why all aspects of your change are correct, in particular about
the corrcetness of the use of temp.

julia

> +		if (err)
> +			return err;
>  		if (index > 255) {
>  			rejected++;
>  			cp = linefeed + 1;
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul
  2017-04-27 16:52 [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul Shekhar Bhandakkar
                   ` (2 preceding siblings ...)
  2017-04-28  5:26 ` Julia Lawall
@ 2017-05-22 14:57 ` Dan Carpenter
  3 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2017-05-22 14:57 UTC (permalink / raw)
  To: kernel-janitors

I happened to search my gmail spam box for patches and found this.

On Fri, Apr 28, 2017 at 6:50 AM, Shekhar Bhandakkar
<cs14btech11006@iith.ac.in> wrote:
> The simple_strtoul function is obsolete.
> This patch replaces it with kstrtoul.
>
> Signed-off-by: Shekhar Bhandakkar <cs14btech11006@iith.ac.in>
> ---
>  drivers/staging/speakup/kobjects.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
> index ca85476..8a1ebe6 100644
> --- a/drivers/staging/speakup/kobjects.c
> +++ b/drivers/staging/speakup/kobjects.c
> @@ -127,6 +127,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,10 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
>                         continue;
>                 }
>
> -               index = simple_strtoul(cp, &temp, 10);
> +               temp = cp;
> +               err = kstrtoul(temp, 10, &index);
> +               if (err)
> +                       return err;

This is buggy.  "temp" is supposed to point to the end of the number.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-05-22 14:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-27 16:52 [PATCH] staging: speakup: Replace simple_strtoul by kstrtoul Shekhar Bhandakkar
2017-04-27 21:58 ` Samuel Thibault
2017-04-28  3:50 ` Shekhar Bhandakkar
2017-04-28  5:26 ` Julia Lawall
2017-05-22 14:57 ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2016-09-12 20:50 Gargi Sharma
     [not found] ` <20160912205630.GG5245@var.home>
2016-09-13  6:32   ` Gargi Sharma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.