From: Eric Biggers Date: Tue, 30 Oct 2018 22:05:30 +0000 (-0700) Subject: lib/parser.c: switch match_number() over to use match_strdup() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=36c8d1e7a27f94b4d812b2a0abf106dab0fa377e;p=linux.git lib/parser.c: switch match_number() over to use match_strdup() 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 Reviewed-by: Andrew Morton Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/lib/parser.c b/lib/parser.c index 618c36ec8efe3..dd70e5e6c9e2f 100644 --- a/lib/parser.c +++ b/lib/parser.c @@ -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);