xfs
[Top] [All Lists]

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

To: xfs@xxxxxxxxxxx
Subject: [PATCH 17/19] mkfs: unit conversions are case insensitive
From: Jan Tulak <jtulak@xxxxxxxxxx>
Date: Thu, 21 Apr 2016 11:39:51 +0200
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1461231593-31294-1-git-send-email-jtulak@xxxxxxxxxx>
References: <1461231593-31294-1-git-send-email-jtulak@xxxxxxxxxx>
Solves the question "Should I use 10g or 10G?"

Signed-off-by: Jan Tulak <jtulak@xxxxxxxxxx>

---
CHANGES:
* use tolower instead of == 'p' || == 'P'
---
 mkfs/xfs_mkfs.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index a6334bc..a35c4a5 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3594,8 +3594,10 @@ cvtnum(
 {
        long long       i;
        char            *sp;
+       int             c;
 
        i = strtoll(s, &sp, 0);
+       c = tolower(*sp);
        if (i == 0 && sp == s)
                return -1LL;
        if (*sp == '\0')
@@ -3606,17 +3608,17 @@ cvtnum(
        if (*sp == 's' && sp[1] == '\0')
                return i * sectsize;
 
-       if (*sp == 'k' && sp[1] == '\0')
+       if (c == 'k' && sp[1] == '\0')
                return 1024LL * i;
-       if (*sp == 'm' && sp[1] == '\0')
+       if (c == 'm' && sp[1] == '\0')
                return 1024LL * 1024LL * i;
-       if (*sp == 'g' && sp[1] == '\0')
+       if (c == 'g' && sp[1] == '\0')
                return 1024LL * 1024LL * 1024LL * i;
-       if (*sp == 't' && sp[1] == '\0')
+       if (c == 't' && sp[1] == '\0')
                return 1024LL * 1024LL * 1024LL * 1024LL * i;
-       if (*sp == 'p' && sp[1] == '\0')
+       if (c == 'p' && sp[1] == '\0')
                return 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * i;
-       if (*sp == 'e' && sp[1] == '\0')
+       if (c == 'e' && sp[1] == '\0')
                return 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * i;
        return -1LL;
 }
-- 
2.5.0

<Prev in Thread] Current Thread [Next in Thread>