From: Martin Peschke <mp3@de.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
Wu Fengguang <wfg@mail.ustc.edu.cn>
Subject: [Patch] small lib/parser.c cleanup
Date: Tue, 06 Mar 2007 20:13:15 +0100 [thread overview]
Message-ID: <1173208395.5266.5.camel@dix> (raw)
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)
reply other threads:[~2007-03-06 19:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1173208395.5266.5.camel@dix \
--to=mp3@de.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=wfg@mail.ustc.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox