* [PATCH] staging/lustre/libcfs: replaced string duplication code with kstrdup
@ 2013-07-12 7:02 Dragos Foianu
2013-07-14 0:20 ` Dilger, Andreas
0 siblings, 1 reply; 2+ messages in thread
From: Dragos Foianu @ 2013-07-12 7:02 UTC (permalink / raw)
To: gregkh; +Cc: andreas.dilger, tao.peng, devel, linux-kernel, Dragos Foianu
Modified cfs_strdup function to use kstrdup instead of duplicating its
implementation.
Found using Coccinelle.
Signed-off-by: Dragos Foianu <dragos.foianu@gmail.com>
---
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.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] staging/lustre/libcfs: replaced string duplication code with kstrdup
2013-07-12 7:02 [PATCH] staging/lustre/libcfs: replaced string duplication code with kstrdup Dragos Foianu
@ 2013-07-14 0:20 ` Dilger, Andreas
0 siblings, 0 replies; 2+ messages in thread
From: Dilger, Andreas @ 2013-07-14 0:20 UTC (permalink / raw)
To: Dragos Foianu
Cc: tao.peng@emc.com, gregkh@linuxfoundation.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
On 2013/12/07 1:02 AM, "Dragos Foianu" <dragos.foianu@gmail.com> wrote:
>Modified cfs_strdup function to use kstrdup instead of duplicating its
>implementation.
>
>Found using Coccinelle.
Thanks for the patch, but in fact this function doesn't appear to be used
in the code anymore and could be removed entirely. Seems that
cfs_vsnprintf() and cfs_snprintf() could also be deleted at the same time.
Cheers, Andreas
>Signed-off-by: Dragos Foianu <dragos.foianu@gmail.com>
>---
> 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);
Cheers, Andreas
--
Andreas Dilger
Lustre Software Architect
Intel High Performance Data Division
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-07-14 0:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-12 7:02 [PATCH] staging/lustre/libcfs: replaced string duplication code with kstrdup Dragos Foianu
2013-07-14 0:20 ` Dilger, Andreas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox