Skip to content

Commit

Permalink
cli: make unit prefixes case insensitive
Browse files Browse the repository at this point in the history
Change-Id: I28544d08217f15b90c3e439bfd9aa75ba0432d07
Signed-off-by: Michael Adam <[email protected]>
  • Loading branch information
obnoxxx committed Dec 21, 2017
1 parent 566627a commit f03d641
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
1 change: 0 additions & 1 deletion cli/gluster-block.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# include "common.h"
# include "block.h"
# include "config.h"
# include <ctype.h>


# define GB_CREATE_HELP_STR "gluster-block create <volname/blockname> "\
Expand Down
20 changes: 9 additions & 11 deletions utils/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# include <time.h>
# include <limits.h>
# include <sys/time.h>
# include <ctype.h>

# define GB_LOGDIR DATADIR "/log/gluster-block"
# define GB_INFODIR DATADIR "/run"
Expand Down

0 comments on commit f03d641

Please sign in to comment.