Re: [PATCH 18/19] mkfs: unit conversions are case insensitive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/24/16 6:15 AM, jtulak@xxxxxxxxxx wrote:
> From: Jan Tulak <jtulak@xxxxxxxxxx>
> 
> Solves the question "Should I use 10g or 10G?"

Might be nicer to do it like the cvtnum in libxcmd:

        c = tolower(*sp);
        switch (c) {
        case 'b':
                return i * blocksize;
...

(hm, why do we have 3 copies of cvtnum?)
 
> Signed-off-by: Jan Tulak <jtulak@xxxxxxxxxx>
> ---
>  mkfs/xfs_mkfs.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 2bb3b35..680c6c4 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -3625,17 +3625,17 @@ cvtnum(
>  	if (*sp == 's' && sp[1] == '\0')
>  		return i * sectsize;
>  
> -	if (*sp == 'k' && sp[1] == '\0')
> +	if ((*sp == 'k'  || *sp == 'K' ) && sp[1] == '\0')
                        ^ 1 space is enough, no?

I guess doing it this way doesn't really bother me, but
the whitespace is messy and if you're here anyway,
tolower() might be simpler.

-Eric

>  		return 1024LL * i;
> -	if (*sp == 'm' && sp[1] == '\0')
> +	if ((*sp == 'm'  || *sp == 'M' ) && sp[1] == '\0')
>  		return 1024LL * 1024LL * i;
> -	if (*sp == 'g' && sp[1] == '\0')
> +	if ((*sp == 'g'  || *sp == 'G' ) && sp[1] == '\0')
>  		return 1024LL * 1024LL * 1024LL * i;
> -	if (*sp == 't' && sp[1] == '\0')
> +	if ((*sp == 't'  || *sp == 'T' ) && sp[1] == '\0')
>  		return 1024LL * 1024LL * 1024LL * 1024LL * i;
> -	if (*sp == 'p' && sp[1] == '\0')
> +	if ((*sp == 'p'  || *sp == 'P' ) && sp[1] == '\0')
>  		return 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * i;
> -	if (*sp == 'e' && sp[1] == '\0')
> +	if ((*sp == 'e'  || *sp == 'E' ) && sp[1] == '\0')
>  		return 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * i;
>  	return -1LL;
>  }
> 

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs



[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux