lkml.org 
[lkml]   [2013]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] lustre:libcfs: remove redundant code.
From
On Fri, Jul 19, 2013 at 5:45 PM, Alexandru Juncu <alexj@rosedu.org> wrote:
> 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);

It would be better if you replaced the calls to cfs_strdup() with
kstrdup() and got rid of cfs_strdup() altogether.


\
 
 \ /
  Last update: 2013-07-19 18:01    [W:0.077 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site