lib/parser: cleanup match_number()
authorNamhyung Kim <namhyung@gmail.com>
Tue, 26 Oct 2010 21:23:09 +0000 (14:23 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 26 Oct 2010 23:52:19 +0000 (16:52 -0700)
Use new variable 'len' to make code more readable.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/parser.c

index fb34977246bb052923d5fad6341c2ba80315fdfe..6e89eca5cca00b6fb059bae5135b0ee381a5d5d5 100644 (file)
@@ -128,12 +128,13 @@ static int match_number(substring_t *s, int *result, int base)
        char *endp;
        char *buf;
        int ret;
+       size_t len = s->to - s->from;
 
-       buf = kmalloc(s->to - s->from + 1, GFP_KERNEL);
+       buf = kmalloc(len + 1, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
-       memcpy(buf, s->from, s->to - s->from);
-       buf[s->to - s->from] = '\0';
+       memcpy(buf, s->from, len);
+       buf[len] = '\0';
        *result = simple_strtol(buf, &endp, base);
        ret = 0;
        if (endp == buf)