staging: lustre: replace simple_strtoul with kstrtoint
PATCH 1/1 staging: lustre: replace simple_strtoul with kstrtoint
Replace simple_strtoul with kstrtoint.simple_strtoul is marked for obsoletion.
--- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/obdclass/obd_mount.c +16 -4
@@ -924,12 +924,24 @@ 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); +int res; + + rc =kstrtoint (s1 +19 ,10 , &res); +if (rc) + lmd->lmd_recovery_time_soft = time_min; +else + lmd->lmd_recovery_time_soft =max_t (int, res, + 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); +int res; + + rc =kstrtoint (s1 +19 ,10 , &res); +if (rc) + lmd->lmd_recovery_time_hard = time_min; +else + lmd->lmd_recovery_time_hard =max_t (int, res, + time_min); clear++; }else if (strncmp (s1,"noir" ,4 ) ==0 ) { lmd->lmd_flags |=LMD_FLG_NOIR ;/* test purpose only. */
Signature · 1 line
2.11.1
Greg Kroah-Hartman
maintainerQuoted 1 line · Marcin Ciupak
Replace
simple_strtoulwith kstrtoint.
Why?
Quoted 15 lines
simple_strtoulis marked for obsoletion.Signed-off-by Marcin Ciupak <[email protected]>--- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)drivers/staging/lustre/lustre/obdclass/obd_mount.c +0
-0@@ -924,12 +924,24 @@ 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 ) {
drivers/staging/lustre/lustre/obdclass/obd_mount.c static int lmd_parse(char *options, struct lustre_mount_data *lmd) · line 934
Quoted 10 lines
drivers/staging/lustre/lustre/obdclass/obd_mount.c +8
-2- lmd->lmd_recovery_time_soft =max_t (int, -simple_strtoul (s1 +19 ,NULL ,10 ), time_min); +int res; + + rc =kstrtoint (s1 +19 ,10 , &res); +if (rc) + lmd->lmd_recovery_time_soft = time_min; +else + lmd->lmd_recovery_time_soft =max_t (int, res, + time_min);
Are you sure this is correct? Do you really want to use max_t()? Why is time_min used if there is an error? Can't this all be written a lot simpler to actually make it semi-sane?
thanks,
greg k-h
Quoted 4 lines · Greg Kroah-Hartman
Quoted 1 line · Marcin Ciupak
Replace
simple_strtoulwith kstrtoint.Why?
Because
Quoted 1 line
Quoted 1 line
simple_strtoulis marked for obsoletion.
as reported by checkpatch.pl.
Quoted 29 lines
Quoted 14 lines
Signed-off-by Marcin Ciupak <[email protected]>--- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)drivers/staging/lustre/lustre/obdclass/obd_mount.c +0
-0@@ -924,12 +924,24 @@ 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 ) {drivers/staging/lustre/lustre/obdclass/obd_mount.c static int lmd_parse(char *options, struct lustre_mount_data *lmd) · line 934
Quoted 10 lines
drivers/staging/lustre/lustre/obdclass/obd_mount.c +8
-2- lmd->lmd_recovery_time_soft =max_t (int, -simple_strtoul (s1 +19 ,NULL ,10 ), time_min); +int res; + + rc =kstrtoint (s1 +19 ,10 , &res); +if (rc) + lmd->lmd_recovery_time_soft = time_min; +else + lmd->lmd_recovery_time_soft =max_t (int, res, + time_min);Are you sure this is correct? Do you really want to use
max_t()? Why istime_minused if there is an error? Can't this all be written a lot simpler to actually make it semi-sane?
Quoted 3 lines
thanks,
greg k-h
max_t() and time_min were already used in the original code, I did not want to change that.
Regarding error handling, I saw two options here:
1. update variable with some fail-safe value and time_min looked good for that or,
2. do not update anything and do nothing or "goto invalid:" but I was not sure about that, so selected first option.
If first option is not the best one, what would be better in case of error handling?
Thanks,
Marcin