Commit 36c8d1e7 authored by Eric Biggers's avatar Eric Biggers Committed by Linus Torvalds

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.orgSigned-off-by: default avatarEric Biggers <ebiggers@google.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4ed97b3c
...@@ -131,13 +131,10 @@ static int match_number(substring_t *s, int *result, int base) ...@@ -131,13 +131,10 @@ static int match_number(substring_t *s, int *result, int base)
char *buf; char *buf;
int ret; int ret;
long val; long val;
size_t len = s->to - s->from;
buf = kmalloc(len + 1, GFP_KERNEL); buf = match_strdup(s);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
memcpy(buf, s->from, len);
buf[len] = '\0';
ret = 0; ret = 0;
val = simple_strtol(buf, &endp, base); val = simple_strtol(buf, &endp, base);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment