diff options
| author | Namhyung Kim <[email protected]> | 2010-10-26 21:23:09 +0000 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2010-10-26 23:52:19 +0000 |
| commit | 5d051decfc27cdf33fbbd2bfca958d0d2c903569 (patch) | |
| tree | 4f6579fdf86218d5214bf76e20e0534ea9a4c5c9 /lib/parser.c | |
| parent | percpu_counter: use this_cpu_ptr() instead of per_cpu_ptr() (diff) | |
| download | kernel-5d051decfc27cdf33fbbd2bfca958d0d2c903569.tar.gz kernel-5d051decfc27cdf33fbbd2bfca958d0d2c903569.zip | |
lib/parser: cleanup match_number()
Use new variable 'len' to make code more readable.
Signed-off-by: Namhyung Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'lib/parser.c')
| -rw-r--r-- | lib/parser.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/parser.c b/lib/parser.c index fb34977246bb..6e89eca5cca0 100644 --- a/lib/parser.c +++ b/lib/parser.c @@ -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) |
