mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandru Juncu <alexj@rosedu.org>
To: gregkh@linuxfoundation.org, andreas.dilger@intel.com, tao.peng@emc.com
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Alexandru Juncu <alexj@rosedu.org>
Subject: [PATCH] lustre:libcfs: remove redundant code.
Date: Fri, 19 Jul 2013 17:45:48 +0300	[thread overview]
Message-ID: <1374245148-24031-1-git-send-email-alexj@rosedu.org> (raw)

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


             reply	other threads:[~2013-07-19 14:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-19 14:45 Alexandru Juncu [this message]
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

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=1374245148-24031-1-git-send-email-alexj@rosedu.org \
    --to=alexj@rosedu.org \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tao.peng@emc.com \
    /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

all inboxes | Powered by JetHome®