lib/parser.c: switch match_number() over to use match_strdup()
authorEric Biggers <ebiggers@google.com>
Tue, 30 Oct 2018 22:05:30 +0000 (15:05 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 31 Oct 2018 15:54:12 +0000 (08:54 -0700)
This simplifies the code.  No change in behavior.

Link: http://lkml.kernel.org/r/20180830194727.191555-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/parser.c

index 618c36ec8efe35278226dd6d8e8b99ead40936f0..dd70e5e6c9e2fa7178b2b338cbd73671339b48d4 100644 (file)
@@ -131,13 +131,10 @@ static int match_number(substring_t *s, int *result, int base)
        char *buf;
        int ret;
        long val;
-       size_t len = s->to - s->from;
 
-       buf = kmalloc(len + 1, GFP_KERNEL);
+       buf = match_strdup(s);
        if (!buf)
                return -ENOMEM;
-       memcpy(buf, s->from, len);
-       buf[len] = '\0';
 
        ret = 0;
        val = simple_strtol(buf, &endp, base);