All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Cc: outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoint
Date: Mon, 22 Feb 2016 13:13:42 -0800	[thread overview]
Message-ID: <20160222211342.GD5849@kroah.com> (raw)
In-Reply-To: <20160222130735.GA26820@amitoj-Inspiron-3542>

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


  reply	other threads:[~2016-02-22 21:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22 13:07 [PATCH] staging: lustre: obdclass: Replace simple_strtoul with kstrtoint Amitoj Kaur Chawla
2016-02-22 21:13 ` Greg KH [this message]
2016-02-23  7:50   ` [Outreachy kernel] " Amitoj Kaur Chawla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160222211342.GD5849@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=amitoj1606@gmail.com \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.