All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoint
@ 2016-02-22 13:07 Amitoj Kaur Chawla
  2016-02-22 21:13 ` [Outreachy kernel] " Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-22 13:07 UTC (permalink / raw)
  To: outreachy-kernel

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, `err` and `val` variables were introduced to store error
code returned by kstrtoint and result of conversion on success
respectively.

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

diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
index 5fa6ce6..29b513e 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
@@ -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_t(int, 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_t(int, val, time_min);
 			clear++;
 		} else if (strncmp(s1, "noir", 4) == 0) {
 			lmd->lmd_flags |= LMD_FLG_NOIR; /* test purpose only. */
-- 
1.9.1



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

* Re: [Outreachy kernel] [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoint
  2016-02-22 13:07 [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoint Amitoj Kaur Chawla
@ 2016-02-22 21:13 ` Greg KH
  2016-02-23  7:50   ` Amitoj Kaur Chawla
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2016-02-22 21:13 UTC (permalink / raw)
  To: Amitoj Kaur Chawla; +Cc: outreachy-kernel

On Mon, Feb 22, 2016 at 06:37:36PM +0530, Amitoj Kaur Chawla wrote:
> 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, `err` and `val` variables were introduced to store error
> code returned by kstrtoint and result of conversion on success
> respectively.
> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/obd_mount.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
> index 5fa6ce6..29b513e 100644
> --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c
> +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
> @@ -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_t(int, val, time_min);

max_t() is no longer needed here, right?  It can just be max().

same for the other use in this patch.

thanks,

greg k-h


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

* Re: [Outreachy kernel] [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoint
  2016-02-22 21:13 ` [Outreachy kernel] " Greg KH
@ 2016-02-23  7:50   ` Amitoj Kaur Chawla
  0 siblings, 0 replies; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-23  7:50 UTC (permalink / raw)
  To: Greg KH; +Cc: outreachy-kernel

On Tue, Feb 23, 2016 at 2:43 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> max_t() is no longer needed here, right?  It can just be max().
>
> same for the other use in this patch.
>
> thanks,
>
> greg k-h

I'll send a v2 with the above change incorporated.

Amitoj


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

end of thread, other threads:[~2016-02-23  7:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-22 13:07 [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoint Amitoj Kaur Chawla
2016-02-22 21:13 ` [Outreachy kernel] " Greg KH
2016-02-23  7:50   ` Amitoj Kaur Chawla

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.