diff options
| author | Namhyung Kim <namhyung@gmail.com> | 2010-10-26 17:23:09 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 19:52:19 -0400 |
| commit | 5d051decfc27cdf33fbbd2bfca958d0d2c903569 (patch) | |
| tree | 4f6579fdf86218d5214bf76e20e0534ea9a4c5c9 /lib/parser.c | |
| parent | ea00c30b5b31baa91be29bee966204eccc15e9d3 (diff) | |
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>
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) | |||
| 128 | char *endp; | 128 | char *endp; |
| 129 | char *buf; | 129 | char *buf; |
| 130 | int ret; | 130 | int ret; |
| 131 | size_t len = s->to - s->from; | ||
| 131 | 132 | ||
| 132 | buf = kmalloc(s->to - s->from + 1, GFP_KERNEL); | 133 | buf = kmalloc(len + 1, GFP_KERNEL); |
| 133 | if (!buf) | 134 | if (!buf) |
| 134 | return -ENOMEM; | 135 | return -ENOMEM; |
| 135 | memcpy(buf, s->from, s->to - s->from); | 136 | memcpy(buf, s->from, len); |
| 136 | buf[s->to - s->from] = '\0'; | 137 | buf[len] = '\0'; |
| 137 | *result = simple_strtol(buf, &endp, base); | 138 | *result = simple_strtol(buf, &endp, base); |
| 138 | ret = 0; | 139 | ret = 0; |
| 139 | if (endp == buf) | 140 | if (endp == buf) |
