lustre:libcfs: remove redundant code.
PATCH 1/1 lustre:libcfs: remove redundant code.
Found using coccinelle. It suggested kmalloc/strcpy should be replaced with kstrdup, but the entire function can be replaced by kstrdup.
--- drivers/staging/lustre/lustre/libcfs/libcfs_string.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/staging/lustre/lustre/libcfs/libcfs_string.c +1 -12
@@ -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);
Signature · 1 line
1.8.1.2
Quoted 21 lines · 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 <[email protected]>--- drivers/staging/lustre/lustre/libcfs/libcfs_string.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)drivers/staging/lustre/lustre/libcfs/libcfs_string.c +0
-5@@ -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 ; -
drivers/staging/lustre/lustre/libcfs/libcfs_string.c EXPORT_SYMBOL(cfs_str2mask); · line 140
Quoted 10 lines
drivers/staging/lustre/lustre/libcfs/libcfs_string.c +1
-7- 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.
Quoted 27 lines · Pekka Enberg
Quoted 26 lines · 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 <[email protected]>--- drivers/staging/lustre/lustre/libcfs/libcfs_string.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)drivers/staging/lustre/lustre/libcfs/libcfs_string.c +0
-10@@ -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);
Quoted 8 lines
drivers/staging/lustre/lustre/libcfs/libcfs_string.c EXPORT_SYMBOL(cfs_str2mask); · line 140
Quoted 5 lines
drivers/staging/lustre/lustre/libcfs/libcfs_string.c +1
-2- -return dup_str; +return kstrdup (str, flags); }EXPORT_SYMBOL (cfs_strdup);It would be better if you replaced the calls to
cfs_strdup()withkstrdup()and got rid ofcfs_strdup()altogether.
I was thinking the same thing, but I hesitated because I didn't know how used it was and I didn't want to break something.
Quoted 2 lines · Alexandru Juncu
I was thinking the same thing, but I hesitated because I didn't know how used it was and I didn't want to break something.
"git grep cfs_strdup" suggests that nobody uses it so you could just remove it completely...
Quoted 6 lines · Pekka Enberg
Quoted 2 lines · Alexandru Juncu
I was thinking the same thing, but I hesitated because I didn't know how used it was and I didn't want to break something.
"git grep
cfs_strdup" suggests that nobody uses it so you could just remove it completely...
Did a grep on the tree and yes, it's not used. But It's in a staging directory so maybe the rest of the code has not been pushed in yet.
Greg Kroah-Hartman
maintainerQuoted 10 lines · Alexandru Juncu
Quoted 6 lines · Pekka Enberg
Quoted 2 lines · Alexandru Juncu
I was thinking the same thing, but I hesitated because I didn't know how used it was and I didn't want to break something.
"git grep
cfs_strdup" suggests that nobody uses it so you could just remove it completely...Did a grep on the tree and yes, it's not used. But It's in a staging directory so maybe the rest of the code has not been pushed in yet.
Doesn't matter, if there are no users, please just remove it.
thanks,
greg k-h
Quoted 1 line · Greg Kroah-Hartman
Doesn't matter, if there are no users, please just remove it.
Is that, basically, your approach to staging cleanups?
I ask because I noticed that "drivers/staging/lustre/lustre/ptlrpc/gss/" is only built if CONFIG_PTLRPC_GSS is set. But the corresponding Kconfig symbol is nowhere to be found.
Or do you prefer that I poke the people involved in (this case in) Lustre before suggesting a drastic cleanup like that?
Paul Bolle
Quoted 11 lines · Paul Bolle
Quoted 1 line · Greg Kroah-Hartman
Doesn't matter, if there are no users, please just remove it.
Is that, basically, your approach to staging cleanups?
I ask because I noticed that "
drivers/staging/lustre/lustre/ptlrpc/gss/" is only built ifCONFIG_PTLRPC_GSSis set. But the correspondingKconfigsymbol is nowhere to be found.Or do you prefer that I poke the people involved in (this case in) Lustre before suggesting a drastic cleanup like that?
Thanks for the comments!
The comment for that function is "Duplicate a string in a platform-independent way" so it might be because it's called by code that also run on non-Linux systems.
Quoted 7 lines
-----Original Message-----
From: Paul Bolle [mailto:[email protected]]
Sent: Saturday, July 20, 2013 12:07 AM
To: Greg Kroah-Hartman
Cc: Alexandru Juncu; Pekka Enberg; andreas.dilger; Peng, Tao; driverdev; LKML
Subject: Re: [PATCH] lustre:libcfs: remove redundant code.
Quoted 9 lines
Quoted 1 line · Greg Kroah-Hartman
Doesn't matter, if there are no users, please just remove it.
Is that, basically, your approach to staging cleanups?
I ask because I noticed that "
drivers/staging/lustre/lustre/ptlrpc/gss/" is only built ifCONFIG_PTLRPC_GSSis set. But the correspondingKconfigsymbol is nowhere to be found.
That's my fault. We certainly _want_ the ptlrpc gss code. I'll get it fixed.
Thanks,
Tao
Quoted 6 lines
Or do you prefer that I poke the people involved in (this case in) Lustre before suggesting a drastic cleanup like that?
Paul Bolle
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 6 lines · Tao
Paul Bolle [mailto:[email protected]]
Quoted 4 lines
I ask because I noticed that "
drivers/staging/lustre/lustre/ptlrpc/gss/" is only built ifCONFIG_PTLRPC_GSSis set. But the correspondingKconfigsymbol is nowhere to be found.That's my fault. We certainly _want_ the ptlrpc gss code. I'll get it fixed.
I'll stop worrying about it. But if little has changed by, say, early 2014, I might try to prod you again.
Thanks!
Paul Bolle
Quoted 6 lines · Greg Kroah-Hartman
Quoted 5 lines · Alexandru Juncu
Quoted 4 lines · Pekka Enberg
Quoted 2 lines · Alexandru Juncu
I was thinking the same thing, but I hesitated because I didn't know how used it was and I didn't want to break something.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
"git grep
cfs_strdup" suggests that nobody uses it so you could just remove it completely...Did a grep on the tree and yes, it's not used. But It's in a staging directory so maybe the rest of the code has not been pushed in yet.
Doesn't matter, if there are no users, please just remove it.
Hi Greg,
There is already a similar patch for this https://lkml.org/lkml/2013/7/17/742,
already reviewed by Andreas Dilger.
thanks,
Daniel.