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

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.