Fixup time multipliers
authorJens Axboe <axboe@fb.com>
Fri, 21 Feb 2014 19:50:09 +0000 (11:50 -0800)
committerJens Axboe <axboe@fb.com>
Fri, 21 Feb 2014 19:50:09 +0000 (11:50 -0800)
Commit 74454ce4 assumed default time is in msec, when it's
in reality usec. Fix that up, and also add a specific 'us'
or 'usec' multiplier (of 1).

Signed-off-by: Jens Axboe <axboe@fb.com>
parse.c

diff --git a/parse.c b/parse.c
index c8bae0335a4e90365022e946d24136b1a1cc501b..5c23d91ebab6c36ea3f6790bac998900015aff20 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -126,7 +126,7 @@ static unsigned long long get_mult_time(const char *str, int len)
 {
        const char *p = str;
        char *c;
-       unsigned long long mult = 1000;
+       unsigned long long mult = 1;
 
        /*
          * Go forward until we hit a non-digit, or +/- sign
@@ -138,22 +138,24 @@ static unsigned long long get_mult_time(const char *str, int len)
        }
 
        if (!isalpha((int) *p))
-               return 1000;
+               return mult;
 
        c = strdup(p);
        for (int i = 0; i < strlen(c); i++)
                c[i] = tolower(c[i]);
 
-       if (!strncmp("ms", c, 2))
+       if (!strncmp("us", c, 2) || !strncmp("usec", c, 4))
                mult = 1;
-       else if (!strcmp("s", c))
+       else if (!strncmp("ms", c, 2) || !strncmp("msec", c, 4))
                mult = 1000;
+       else if (!strcmp("s", c))
+               mult = 1000000;
        else if (!strcmp("m", c))
-               mult = 60 * 1000;
+               mult = 60 * 1000000UL;
        else if (!strcmp("h", c))
-               mult = 60 * 60 * 1000;
+               mult = 60 * 60 * 1000000UL;
        else if (!strcmp("d", c))
-               mult = 24 * 60 * 60 * 1000;
+               mult = 24 * 60 * 60 * 1000000UL;
 
        free(c);
        return mult;