* [PATCH] lib/parser.c: switch match_number() over to use match_strdup()
@ 2018-08-30 19:47 Eric Biggers
2018-09-05 1:39 ` Eric Biggers
0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2018-08-30 19:47 UTC (permalink / raw)
To: linux-kernel, Andrew Morton; +Cc: Eric Biggers
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lib/parser.c: switch match_number() over to use match_strdup()
2018-08-30 19:47 [PATCH] lib/parser.c: switch match_number() over to use match_strdup() Eric Biggers
@ 2018-09-05 1:39 ` Eric Biggers
0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2018-09-05 1:39 UTC (permalink / raw)
To: linux-kernel, Andrew Morton
On Thu, Aug 30, 2018 at 12:47:27PM -0700, Eric Biggers wrote:
> 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);
> --
Hi Andrew, are you planning to take this patch too? The similar patch
lib/parser.c: switch match_u64int() over to use match_strdup()
is in -mm now, but this one is not.
Thanks,
- Eric
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-05 1:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-30 19:47 [PATCH] lib/parser.c: switch match_number() over to use match_strdup() Eric Biggers
2018-09-05 1:39 ` Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).