Skip to contentSkip to conversation

staging: lustre: obdclass: Replace simple_stroul with kstrtoint

PATCH New Amitoj Kaur Chawla 1 participant 1 message Feb 23, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: lustre: obdclass: Replace simple_stroul with kstrtoint

Replace obsolete simple_strtoul with kstrtoint.
This change was made with the help of the following Coccinelle semantic patch:

// <smpl>
@@
expression e,g;
@@
(
* simple_strtoul(e, NULL, g)
|
* simple_strtol(e, NULL, g)
|
* simple_strtoull(e, NULL, g)
)
// </smpl>

Additionally, changed max_t() to max() since the variables are of the same type.

---
Changes in v2:
-Replaced max_t() with max()

 drivers/staging/lustre/lustre/obdclass/obd_mount.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/obdclass/obd_mount.c +9 -4
index 5fa6ce6..dca25f36 100644
@@ -900,6 +900,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
 	while (*s1) {
 		int clear = 0;
 		int time_min = OBD_RECOVERY_TIME_MIN;
+		int val, err;
 
 		/* Skip whitespace and extra commas */
 		while (*s1 == ' ' || *s1 == ',')
@@ -914,12 +915,16 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
 			lmd->lmd_flags |= LMD_FLG_ABORT_RECOV;
 			clear++;
 		} else if (strncmp(s1, "recovery_time_soft=", 19) == 0) {
-			lmd->lmd_recovery_time_soft = max_t(int,
-				simple_strtoul(s1 + 19, NULL, 10), time_min);
+			err = kstrtoint(s1 + 19, 10, &val);
+			if (err)
+				return err;
+			lmd->lmd_recovery_time_soft = max(val, time_min);
 			clear++;
 		} else if (strncmp(s1, "recovery_time_hard=", 19) == 0) {
-			lmd->lmd_recovery_time_hard = max_t(int,
-				simple_strtoul(s1 + 19, NULL, 10), time_min);
+			err = kstrtoint(s1 + 19, 10, &val);
+			if (err)
+				return err;
+			lmd->lmd_recovery_time_hard = max(val, time_min);
 			clear++;
 		} else if (strncmp(s1, "noir", 4) == 0) {
 			lmd->lmd_flags |= LMD_FLG_NOIR; /* test purpose only. */
Signature · 1 line
1.9.1