From f03d6410625c2a606904e8bafb7096181ea9b5a0 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Dec 2017 13:29:03 +0100 Subject: cli: make unit prefixes case insensitive Change-Id: I28544d08217f15b90c3e439bfd9aa75ba0432d07 Signed-off-by: Michael Adam --- cli/gluster-block.c | 1 - utils/common.c | 20 +++++++++----------- utils/utils.h | 1 + 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cli/gluster-block.c b/cli/gluster-block.c index 0196437..53f72bc 100644 --- a/cli/gluster-block.c +++ b/cli/gluster-block.c @@ -12,7 +12,6 @@ # include "common.h" # include "block.h" # include "config.h" -# include # define GB_CREATE_HELP_STR "gluster-block create "\ diff --git a/utils/common.c b/utils/common.c index 4b9237f..98cc0ef 100644 --- a/utils/common.c +++ b/utils/common.c @@ -59,33 +59,31 @@ glusterBlockParseSize(const char *dom, char *value) tmp = tmp + 1; } - switch (*tmp) { - case 'Y': + switch (tolower(*tmp)) { + case 'y': sizef *= 1024; /* fall through */ - case 'Z': + case 'z': sizef *= 1024; /* fall through */ - case 'E': + case 'e': sizef *= 1024; /* fall through */ - case 'P': + case 'p': sizef *= 1024; /* fall through */ - case 'T': + case 't': sizef *= 1024; /* fall through */ - case 'G': + case 'g': sizef *= 1024; /* fall through */ - case 'M': + case 'm': sizef *= 1024; /* fall through */ - case 'K': case 'k': sizef *= 1024; /* fall through */ - case 'B': case 'b': case '\0': break; @@ -106,7 +104,7 @@ glusterBlockParseSize(const char *dom, char *value) fail: LOG(dom, GB_LOG_ERROR, "%s", "Unknown size unit. " - "You may use b/B, k/K(iB), M(iB), G(iB), and T(iB) suffixes for " + "You may use b/B, k/K(iB), m/M(iB), g/G(iB), and t/T(iB) suffixes for " "bytes, kibibytes, mebibytes, gibibytes, and tebibytes."); return -1; } diff --git a/utils/utils.h b/utils/utils.h index bd073ad..8a30d25 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -24,6 +24,7 @@ # include # include # include +# include # define GB_LOGDIR DATADIR "/log/gluster-block" # define GB_INFODIR DATADIR "/run" -- cgit