All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Liu <jeff.liu@oracle.com>
To: Abhijit Pawar <abhi.c.pawar@gmail.com>
Cc: Ben Myers <bpm@sgi.com>, Alex Elder <elder@kernel.org>,
	linux-kernel@vger.kernel.org, xfs@oss.sgi.com
Subject: Re: [PATCH 1/1] fs/xfs remove obsolete simple_strto<foo>
Date: Sat, 12 Jan 2013 10:54:19 +0800	[thread overview]
Message-ID: <50F0D05B.5030507@oracle.com> (raw)
In-Reply-To: <1357740282-2377-1-git-send-email-abhi.c.pawar@gmail.com>

On 01/09/2013 10:04 PM, Abhijit Pawar wrote:
> This patch replaces usages of obsolete simple_strtoul with kstrtoint in xfs_args and suffix_strtoul.
> 
> Signed-off-by: Abhijit Pawar <abhi.c.pawar@gmail.com>
> ---
>  fs/xfs/xfs_super.c |   29 +++++++++++++++++++----------
>  1 files changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index ab8839b..c407121 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -139,9 +139,9 @@ static const match_table_t tokens = {
>  
>  
>  STATIC unsigned long
> -suffix_strtoul(char *s, char **endp, unsigned int base)
> +suffix_kstrtoint(char *s, unsigned int base, int *res)
>  {
> -	int	last, shift_left_factor = 0;
> +	int	last, shift_left_factor = 0, _res;
>  	char	*value = s;
>  
>  	last = strlen(value) - 1;
> @@ -158,7 +158,10 @@ suffix_strtoul(char *s, char **endp, unsigned int base)
>  		value[last] = '\0';
>  	}
>  
> -	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
> +	if (kstrtoint(s, base, &_res))
> +		return -EINVAL;
> +	*res = _res << shift_left_factor;
> +	return 0;
>  }
>  
>  /*
> @@ -174,7 +177,7 @@ xfs_parseargs(
>  	char			*options)
>  {
>  	struct super_block	*sb = mp->m_super;
> -	char			*this_char, *value, *eov;
> +	char			*this_char, *value;
>  	int			dsunit = 0;
>  	int			dswidth = 0;
>  	int			iosize = 0;
> @@ -230,14 +233,16 @@ xfs_parseargs(
>  					this_char);
>  				return EINVAL;
>  			}
> -			mp->m_logbufs = simple_strtoul(value, &eov, 10);
> +			if (kstrtoint(value, 10, &mp->m_logbufs))
> +				return EINVAL;
>  		} else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
>  			if (!value || !*value) {
>  				xfs_warn(mp, "%s option requires an argument",
>  					this_char);
>  				return EINVAL;
>  			}
> -			mp->m_logbsize = suffix_strtoul(value, &eov, 10);
> +			if (suffix_kstrtoint(value, 10, &mp->m_logbsize))
> +				return EINVAL;
>  		} else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
>  			if (!value || !*value) {
>  				xfs_warn(mp, "%s option requires an argument",
> @@ -266,7 +271,8 @@ xfs_parseargs(
>  					this_char);
>  				return EINVAL;
>  			}
> -			iosize = simple_strtoul(value, &eov, 10);
> +			if (kstrtoint(value, 10, &iosize))
> +				return EINVAL;
>  			iosizelog = ffs(iosize) - 1;
>  		} else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
>  			if (!value || !*value) {
> @@ -274,7 +280,8 @@ xfs_parseargs(
>  					this_char);
>  				return EINVAL;
>  			}
> -			iosize = suffix_strtoul(value, &eov, 10);
> +			if (suffix_kstrtoint(value, 10, &iosize))
> +				return EINVAL;
>  			iosizelog = ffs(iosize) - 1;
>  		} else if (!strcmp(this_char, MNTOPT_GRPID) ||
>  			   !strcmp(this_char, MNTOPT_BSDGROUPS)) {
> @@ -296,14 +303,16 @@ xfs_parseargs(
>  					this_char);
>  				return EINVAL;
>  			}
> -			dsunit = simple_strtoul(value, &eov, 10);
> +			if (kstrtoint(value, 10, &dsunit))
> +				return EINVAL;
>  		} else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
>  			if (!value || !*value) {
>  				xfs_warn(mp, "%s option requires an argument",
>  					this_char);
>  				return EINVAL;
>  			}
> -			dswidth = simple_strtoul(value, &eov, 10);
> +			if (kstrtoint(value, 10, &dswidth))
> +				return EINVAL;
>  		} else if (!strcmp(this_char, MNTOPT_32BITINODE)) {
>  			mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
>  		} else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
> 
Reviewed-by: Jie Liu <jeff.liu@oracle.com>

      parent reply	other threads:[~2013-01-12  2:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-09 14:04 [PATCH 1/1] fs/xfs remove obsolete simple_strto<foo> Abhijit Pawar
2013-01-11  6:36 ` Jeff Liu
2013-01-11  7:46   ` Abhijit Pawar
2013-01-11 19:09     ` Ben Myers
2013-01-11 22:52   ` Dave Chinner
2013-01-12  2:48     ` Jeff Liu
2013-01-12  2:54 ` Jeff Liu [this message]

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=50F0D05B.5030507@oracle.com \
    --to=jeff.liu@oracle.com \
    --cc=abhi.c.pawar@gmail.com \
    --cc=bpm@sgi.com \
    --cc=elder@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xfs@oss.sgi.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.