staging: lustre: obdclass: Replace simple_strtoul with kstrtoul
PATCH 1/1 staging: lustre: obdclass: 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/lustre/lustre/obdclass/lprocfs_status.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +4 -1
@@ -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 ;
Signature · 1 line
1.9.1
Quoted 27 lines · Amitoj Kaur Chawla
Replace obsolete
simple_strtoulwith 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
errvariable to store and return the error code. This change was made by hand.Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +0
-0@@ -343,12 +343,15 @@ int lprocfs_wr_uint(struct file *file, const char __user *buffer,unsigned *p = data;
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c int lprocfs_wr_uint(struct file *file, const char __user *buffer, · line 352
Quoted 10 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +2
-1char 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
Quoted 15 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +2
-1+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 [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/20160222123259.GA24119%40amitoj-Inspiron-3542.
For more options, visit https://groups.google.com/d/optout.
Quoted 8 lines · Julia Lawall
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c int lprocfs_wr_uint(struct file *file, const char __user *buffer, · line 352
Quoted 3 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +1
-1- 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
Quoted 10 lines · Amitoj Kaur Chawla
Quoted 8 lines · Julia Lawall
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c int lprocfs_wr_uint(struct file *file, const char __user *buffer, · line 352
Quoted 3 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +1
-1- 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
Quoted 10 lines
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 [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/CA%2B5yK5E1mFFcR6a4BKBa7Rq1UmpRUumiAiy7Wv53TD%3DQe%2BPjdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Greg KH
maintainerQuoted 11 lines · Amitoj Kaur Chawla
Replace obsolete
simple_strtoulwith 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