All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoul
@ 2016-02-22 12:32 Amitoj Kaur Chawla
  2016-02-22 12:36 ` [Outreachy kernel] " Julia Lawall
  2016-02-22 21:12 ` Greg KH
  0 siblings, 2 replies; 5+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-22 12:32 UTC (permalink / raw)
  To: outreachy-kernel

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.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 16b1c70..0abf941 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -343,12 +343,15 @@ int lprocfs_wr_uint(struct file *file, const char __user *buffer,
 	unsigned *p = data;
 	char dummy[MAX_STRING_SIZE + 1], *end;
 	unsigned long tmp;
+	int err;
 
 	dummy[MAX_STRING_SIZE] = '\0';
 	if (copy_from_user(dummy, buffer, MAX_STRING_SIZE))
 		return -EFAULT;
 
-	tmp = simple_strtoul(dummy, &end, 0);
+	err = kstrtoul(dummy, 0, &tmp);
+	if (err)
+		return err;
 	if (dummy == end)
 		return -EINVAL;
 
-- 
1.9.1



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

* Re: [Outreachy kernel] [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoul
  2016-02-22 12:32 [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoul Amitoj Kaur Chawla
@ 2016-02-22 12:36 ` Julia Lawall
  2016-02-22 12:40   ` Amitoj Kaur Chawla
  2016-02-22 21:12 ` Greg KH
  1 sibling, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2016-02-22 12:36 UTC (permalink / raw)
  To: Amitoj Kaur Chawla; +Cc: outreachy-kernel

On Mon, 22 Feb 2016, Amitoj Kaur Chawla wrote:

> 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.
>
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index 16b1c70..0abf941 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -343,12 +343,15 @@ int lprocfs_wr_uint(struct file *file, const char __user *buffer,
>  	unsigned *p = data;
>  	char dummy[MAX_STRING_SIZE + 1], *end;
>  	unsigned long tmp;
> +	int err;
>
>  	dummy[MAX_STRING_SIZE] = '\0';
>  	if (copy_from_user(dummy, buffer, MAX_STRING_SIZE))
>  		return -EFAULT;
>
> -	tmp = simple_strtoul(dummy, &end, 0);
> +	err = kstrtoul(dummy, 0, &tmp);

This doesn't look correct.  end is not being initialized any more.

julia

> +	if (err)
> +		return err;
>  	if (dummy == end)
>  		return -EINVAL;
>
> --
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160222123259.GA24119%40amitoj-Inspiron-3542.
> For more options, visit https://groups.google.com/d/optout.
>


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

* Re: [Outreachy kernel] [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoul
  2016-02-22 12:36 ` [Outreachy kernel] " Julia Lawall
@ 2016-02-22 12:40   ` Amitoj Kaur Chawla
  2016-02-22 12:42     ` Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-22 12:40 UTC (permalink / raw)
  To: Julia Lawall; +Cc: outreachy-kernel

On Mon, Feb 22, 2016 at 6:06 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>>
>> -     tmp = simple_strtoul(dummy, &end, 0);
>> +     err = kstrtoul(dummy, 0, &tmp);
>
> This doesn't look correct.  end is not being initialized any more.
>
> julia
>
Any other way I should go about it? Or I'll have to drop this?

Amitoj


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

* Re: [Outreachy kernel] [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoul
  2016-02-22 12:40   ` Amitoj Kaur Chawla
@ 2016-02-22 12:42     ` Julia Lawall
  0 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2016-02-22 12:42 UTC (permalink / raw)
  To: Amitoj Kaur Chawla; +Cc: outreachy-kernel

On Mon, 22 Feb 2016, Amitoj Kaur Chawla wrote:

> On Mon, Feb 22, 2016 at 6:06 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >>
> >> -     tmp = simple_strtoul(dummy, &end, 0);
> >> +     err = kstrtoul(dummy, 0, &tmp);
> >
> > This doesn't look correct.  end is not being initialized any more.
> >
> > julia
> >
> Any other way I should go about it? Or I'll have to drop this?

I don't know.  Look at what end is supposed to point to, and see if
kstroul can do that.  But it may be necessary to just drop it.

julia


>
> Amitoj
>
> --
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CA%2B5yK5E1mFFcR6a4BKBa7Rq1UmpRUumiAiy7Wv53TD%3DQe%2BPjdA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


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

* Re: [Outreachy kernel] [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoul
  2016-02-22 12:32 [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoul Amitoj Kaur Chawla
  2016-02-22 12:36 ` [Outreachy kernel] " Julia Lawall
@ 2016-02-22 21:12 ` Greg KH
  1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2016-02-22 21:12 UTC (permalink / raw)
  To: Amitoj Kaur Chawla; +Cc: outreachy-kernel

On Mon, Feb 22, 2016 at 06:02:59PM +0530, Amitoj Kaur Chawla wrote:
> 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>

As you are finding out, it's not as simple as this for this type of
conversion, which is why we haven't just swept the whole kernel tree by
now and done this :(

sorry,

greg k-h


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

end of thread, other threads:[~2016-02-22 21:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-22 12:32 [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoul Amitoj Kaur Chawla
2016-02-22 12:36 ` [Outreachy kernel] " Julia Lawall
2016-02-22 12:40   ` Amitoj Kaur Chawla
2016-02-22 12:42     ` Julia Lawall
2016-02-22 21:12 ` Greg KH

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.