All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lustre:libcfs: remove redundant code.
@ 2013-07-19 14:45 Alexandru Juncu
  2013-07-19 15:08 ` Pekka Enberg
  0 siblings, 1 reply; 11+ messages in thread
From: Alexandru Juncu @ 2013-07-19 14:45 UTC (permalink / raw)
  To: gregkh, andreas.dilger, tao.peng; +Cc: devel, linux-kernel, Alexandru Juncu

Found using coccinelle. It suggested kmalloc/strcpy should be replaced
with kstrdup, but the entire function can be replaced by kstrdup.

Signed-off-by: Alexandru Juncu <alexj@rosedu.org>
---
 drivers/staging/lustre/lustre/libcfs/libcfs_string.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
index 9edccc9..4dba304 100644
--- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
+++ b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
@@ -135,18 +135,7 @@ EXPORT_SYMBOL(cfs_str2mask);
 /* Duplicate a string in a platform-independent way */
 char *cfs_strdup(const char *str, u_int32_t flags)
 {
-	size_t lenz; /* length of str + zero byte */
-	char *dup_str;
-
-	lenz = strlen(str) + 1;
-
-	dup_str = kmalloc(lenz, flags);
-	if (dup_str == NULL)
-		return NULL;
-
-	memcpy(dup_str, str, lenz);
-
-	return dup_str;
+	return kstrdup(str, flags);
 }
 EXPORT_SYMBOL(cfs_strdup);
 
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-07-22  9:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-19 14:45 [PATCH] lustre:libcfs: remove redundant code Alexandru Juncu
2013-07-19 15:08 ` Pekka Enberg
2013-07-19 15:13   ` Alexandru Juncu
2013-07-19 15:21     ` Pekka Enberg
2013-07-19 15:29       ` Alexandru Juncu
2013-07-19 15:46         ` Greg Kroah-Hartman
2013-07-19 16:07           ` Paul Bolle
2013-07-19 16:22             ` Alexandru Juncu
2013-07-22  2:07             ` Peng, Tao
2013-07-22  9:04               ` Paul Bolle
2013-07-19 16:29           ` Daniel Baluta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.