mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 17:11:46 +00:00
lib/parser: cleanup match_number()
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>
This commit is contained in:
parent
ea00c30b5b
commit
5d051decfc
1 changed files with 4 additions and 3 deletions
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue