Skip to content

Commit

Permalink
lib/parser: cleanup match_number()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
namhyung authored and torvalds committed Oct 26, 2010
1 parent ea00c30 commit 5d051de
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ static int match_number(substring_t *s, int *result, int base)
char *endp;
char *buf;
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)
return -ENOMEM;
memcpy(buf, s->from, s->to - s->from);
buf[s->to - s->from] = '\0';
memcpy(buf, s->from, len);
buf[len] = '\0';
*result = simple_strtol(buf, &endp, base);
ret = 0;
if (endp == buf)
Expand Down

0 comments on commit 5d051de

Please sign in to comment.