From a03fb65f4e5d657ee3bb68309cfa70ae2d5bc44b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 29 Mar 2013 12:20:51 -0600 Subject: [PATCH] parse: fix misparse of bs=64k-128k 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 --- parse.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/parse.c b/parse.c index 51cefcae..5b8e10f9 100644 --- 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) { @@ -153,8 +166,13 @@ static unsigned long long __get_mult_bytes(const char *p, void *data, c = strdup(p); - for (i = 0; i < strlen(c); i++) + for (i = 0; i < strlen(c); i++) { c[i] = tolower(c[i]); + if (is_separator(c[i])) { + c[i] = '\0'; + break; + } + } if (!strcmp("pib", c)) { pow = 5; -- 2.25.1