* [Patch] small lib/parser.c cleanup
@ 2007-03-06 19:13 Martin Peschke
0 siblings, 0 replies; only message in thread
From: Martin Peschke @ 2007-03-06 19:13 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, linux-s390, Wu Fengguang
simplifying code by using available string duplication function
Signed-off-by: Martin Peschke <mp3@de.ibm.com>
---
parser.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
Index: linux/lib/parser.c
===================================================================
--- linux.orig/lib/parser.c
+++ linux/lib/parser.c
@@ -126,11 +126,9 @@ static int match_number(substring_t *s,
char *buf;
int ret;
- buf = kmalloc(s->to - s->from + 1, GFP_KERNEL);
+ buf = match_strdup(s);
if (!buf)
return -ENOMEM;
- memcpy(buf, s->from, s->to - s->from);
- buf[s->to - s->from] = '\0';
*result = simple_strtol(buf, &endp, base);
ret = 0;
if (endp == buf)
@@ -155,11 +153,9 @@ int match_s64(substring_t *s, s64 *resul
char *buf;
int ret;
- buf = kmalloc(s->to - s->from + 1, GFP_KERNEL);
+ buf = match_strdup(s);
if (!buf)
return -ENOMEM;
- memcpy(buf, s->from, s->to - s->from);
- buf[s->to - s->from] = '\0';
*result = simple_strtoll(buf, &endp, base);
ret = 0;
if (endp == buf)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-03-06 19:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-06 19:13 [Patch] small lib/parser.c cleanup Martin Peschke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox