Patchwork [2/4] strtosz() use qemu_toupper() to simplify switch statement

login
register
mail settings
Submitter Jes Sorensen
Date Jan. 24, 2011, 3:33 p.m.
Message ID <1295883211-18288-3-git-send-email-Jes.Sorensen@redhat.com>
Download mbox | patch
Permalink /patch/80181/
State New
Headers show

Comments

Jes Sorensen - Jan. 24, 2011, 3:33 p.m.
From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 cutils.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

Patch

diff --git a/cutils.c b/cutils.c
index a067cf4..78d35e2 100644
--- a/cutils.c
+++ b/cutils.c
@@ -323,16 +323,14 @@  int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
             d = c;
         }
     }
-    switch (d) {
+    switch (qemu_toupper(d)) {
     case 'B':
-    case 'b':
         mul = 1;
         if (mul_required) {
             goto fail;
         }
         break;
     case 'K':
-    case 'k':
         mul = 1 << 10;
         break;
     case 0:
@@ -340,15 +338,12 @@  int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
             goto fail;
         }
     case 'M':
-    case 'm':
         mul = 1ULL << 20;
         break;
     case 'G':
-    case 'g':
         mul = 1ULL << 30;
         break;
     case 'T':
-    case 't':
         mul = 1ULL << 40;
         break;
     default: