lkml.org 
[lkml]   [2018]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] lib/parser.c: switch match_number() over to use match_strdup()
Date
From: Eric Biggers <ebiggers@google.com>

This simplifies the code. No change in behavior.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
lib/parser.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lib/parser.c b/lib/parser.c
index 0142ef28f0eb..96656a6dd59b 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -131,13 +131,10 @@ static int match_number(substring_t *s, int *result, int base)
char *buf;
int ret;
long val;
- size_t len = s->to - s->from;

- buf = kmalloc(len + 1, GFP_KERNEL);
+ buf = match_strdup(s);
if (!buf)
return -ENOMEM;
- memcpy(buf, s->from, len);
- buf[len] = '\0';

ret = 0;
val = simple_strtol(buf, &endp, base);
--
2.19.0.rc0.228.g281dcd1b4d0-goog
\
 
 \ /
  Last update: 2018-08-30 22:19    [W:0.056 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site