parse: fix misparse of bs=64k-128k
authorJens Axboe <axboe@kernel.dk>
Fri, 29 Mar 2013 18:20:51 +0000 (12:20 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 29 Mar 2013 18:20:51 +0000 (12:20 -0600)
We failed parsing the postfix for this case, resulting in
64 and 128k being the result (instead of 64k and 128k).

Signed-off-by: Jens Axboe <axboe@kernel.dk>
parse.c

diff --git a/parse.c b/parse.c
index 51cefcaef4abd3d93db61e658d5ae4c29b6d437a..5b8e10f9f2e936ef55817c2d44b291e7c868e9f4 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -140,6 +140,19 @@ static unsigned long get_mult_time(char c)
        }
 }
 
        }
 }
 
+static int is_separator(char c)
+{
+       switch (c) {
+       case ':':
+       case '-':
+       case ',':
+       case '/':
+               return 1;
+       default:
+               return 0;
+       }
+}
+
 static unsigned long long __get_mult_bytes(const char *p, void *data,
                                           int *percent)
 {
 static unsigned long long __get_mult_bytes(const char *p, void *data,
                                           int *percent)
 {
@@ -153,8 +166,13 @@ static unsigned long long __get_mult_bytes(const char *p, void *data,
 
        c = strdup(p);
 
 
        c = strdup(p);
 
-       for (i = 0; i < strlen(c); i++)
+       for (i = 0; i < strlen(c); i++) {
                c[i] = tolower(c[i]);
                c[i] = tolower(c[i]);
+               if (is_separator(c[i])) {
+                       c[i] = '\0';
+                       break;
+               }
+       }
 
        if (!strcmp("pib", c)) {
                pow = 5;
 
        if (!strcmp("pib", c)) {
                pow = 5;