[patch 21/96] lib/parser.c: switch match_u64int() over to use match_strdup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Eric Biggers <ebiggers@xxxxxxxxxx>
Subject: lib/parser.c: switch match_u64int() over to use match_strdup()

This simplifies the code.  No change in behavior.

Link: http://lkml.kernel.org/r/20180830194814.192880-1-ebiggers@xxxxxxxxxx
Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 lib/parser.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

--- a/lib/parser.c~lib-parserc-switch-match_u64int-over-to-use-match_strdup
+++ a/lib/parser.c
@@ -166,13 +166,10 @@ static int match_u64int(substring_t *s,
 	char *buf;
 	int ret;
 	u64 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 = kstrtoull(buf, base, &val);
 	if (!ret)
_



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux