Skip to content
Snippets Groups Projects
Commit 5d051dec authored by Namhyung Kim's avatar Namhyung Kim Committed by Linus Torvalds
Browse files

lib/parser: cleanup match_number()


Use new variable 'len' to make code more readable.

Signed-off-by: default avatarNamhyung Kim <namhyung@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ea00c30b
No related branches found
No related tags found
No related merge requests found
...@@ -128,12 +128,13 @@ static int match_number(substring_t *s, int *result, int base) ...@@ -128,12 +128,13 @@ static int match_number(substring_t *s, int *result, int base)
char *endp; char *endp;
char *buf; char *buf;
int ret; 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) if (!buf)
return -ENOMEM; return -ENOMEM;
memcpy(buf, s->from, s->to - s->from); memcpy(buf, s->from, len);
buf[s->to - s->from] = '\0'; buf[len] = '\0';
*result = simple_strtol(buf, &endp, base); *result = simple_strtol(buf, &endp, base);
ret = 0; ret = 0;
if (endp == buf) if (endp == buf)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment