* [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* Re: [PATCH] lustre:libcfs: remove redundant code.
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
0 siblings, 1 reply; 11+ messages in thread
From: Pekka Enberg @ 2013-07-19 15:08 UTC (permalink / raw)
To: Alexandru Juncu
Cc: Greg Kroah-Hartman, andreas.dilger, tao.peng, driverdev, LKML
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.
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] lustre:libcfs: remove redundant code.
2013-07-19 15:08 ` Pekka Enberg
@ 2013-07-19 15:13 ` Alexandru Juncu
2013-07-19 15:21 ` Pekka Enberg
0 siblings, 1 reply; 11+ messages in thread
From: Alexandru Juncu @ 2013-07-19 15:13 UTC (permalink / raw)
To: Pekka Enberg
Cc: Greg Kroah-Hartman, andreas.dilger, tao.peng, driverdev, LKML
On 19 July 2013 18:08, Pekka Enberg <penberg@kernel.org> wrote:
> 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.
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.
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] lustre:libcfs: remove redundant code.
2013-07-19 15:13 ` Alexandru Juncu
@ 2013-07-19 15:21 ` Pekka Enberg
2013-07-19 15:29 ` Alexandru Juncu
0 siblings, 1 reply; 11+ messages in thread
From: Pekka Enberg @ 2013-07-19 15:21 UTC (permalink / raw)
To: Alexandru Juncu
Cc: Greg Kroah-Hartman, andreas.dilger, tao.peng, driverdev, LKML
On Fri, Jul 19, 2013 at 6:13 PM, Alexandru Juncu <alexj@rosedu.org> wrote:
> 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...
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] lustre:libcfs: remove redundant code.
2013-07-19 15:21 ` Pekka Enberg
@ 2013-07-19 15:29 ` Alexandru Juncu
2013-07-19 15:46 ` Greg Kroah-Hartman
0 siblings, 1 reply; 11+ messages in thread
From: Alexandru Juncu @ 2013-07-19 15:29 UTC (permalink / raw)
To: Pekka Enberg
Cc: Greg Kroah-Hartman, andreas.dilger, tao.peng, driverdev, LKML
On 19 July 2013 18:21, Pekka Enberg <penberg@kernel.org> wrote:
> On Fri, Jul 19, 2013 at 6:13 PM, Alexandru Juncu <alexj@rosedu.org> wrote:
>> 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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] lustre:libcfs: remove redundant code.
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:29 ` Daniel Baluta
0 siblings, 2 replies; 11+ messages in thread
From: Greg Kroah-Hartman @ 2013-07-19 15:46 UTC (permalink / raw)
To: Alexandru Juncu; +Cc: Pekka Enberg, andreas.dilger, tao.peng, driverdev, LKML
On Fri, Jul 19, 2013 at 06:29:34PM +0300, Alexandru Juncu wrote:
> On 19 July 2013 18:21, Pekka Enberg <penberg@kernel.org> wrote:
> > On Fri, Jul 19, 2013 at 6:13 PM, Alexandru Juncu <alexj@rosedu.org> wrote:
> >> 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] lustre:libcfs: remove redundant code.
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-19 16:29 ` Daniel Baluta
1 sibling, 2 replies; 11+ messages in thread
From: Paul Bolle @ 2013-07-19 16:07 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Alexandru Juncu, Pekka Enberg, andreas.dilger, tao.peng,
driverdev, LKML
On Fri, 2013-07-19 at 08:46 -0700, Greg Kroah-Hartman wrote:
> 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] lustre:libcfs: remove redundant code.
2013-07-19 16:07 ` Paul Bolle
@ 2013-07-19 16:22 ` Alexandru Juncu
2013-07-22 2:07 ` Peng, Tao
1 sibling, 0 replies; 11+ messages in thread
From: Alexandru Juncu @ 2013-07-19 16:22 UTC (permalink / raw)
To: Paul Bolle
Cc: Greg Kroah-Hartman, Pekka Enberg, andreas.dilger, tao.peng,
driverdev, LKML
On 19 July 2013 19:07, Paul Bolle <pebolle@tiscali.nl> wrote:
> On Fri, 2013-07-19 at 08:46 -0700, Greg Kroah-Hartman wrote:
>> 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?
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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] lustre:libcfs: remove redundant code.
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
1 sibling, 1 reply; 11+ messages in thread
From: Peng, Tao @ 2013-07-22 2:07 UTC (permalink / raw)
To: Paul Bolle, Greg Kroah-Hartman
Cc: Alexandru Juncu, Pekka Enberg, andreas.dilger, LKML
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1063 bytes --]
> -----Original Message-----
> From: Paul Bolle [mailto:pebolle@tiscali.nl]
> 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.
>
> On Fri, 2013-07-19 at 08:46 -0700, Greg Kroah-Hartman wrote:
> > 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.
>
That's my fault. We certainly _want_ the ptlrpc gss code. I'll get it fixed.
Thanks,
Tao
> 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Ç+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] lustre:libcfs: remove redundant code.
2013-07-22 2:07 ` Peng, Tao
@ 2013-07-22 9:04 ` Paul Bolle
0 siblings, 0 replies; 11+ messages in thread
From: Paul Bolle @ 2013-07-22 9:04 UTC (permalink / raw)
To: Peng, Tao
Cc: Greg Kroah-Hartman, Alexandru Juncu, Pekka Enberg, andreas.dilger,
LKML
On Mon, 2013-07-22 at 02:07 +0000, Peng, Tao wrote:
> Paul Bolle [mailto:pebolle@tiscali.nl]
> > 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.
> >
> 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] lustre:libcfs: remove redundant code.
2013-07-19 15:46 ` Greg Kroah-Hartman
2013-07-19 16:07 ` Paul Bolle
@ 2013-07-19 16:29 ` Daniel Baluta
1 sibling, 0 replies; 11+ messages in thread
From: Daniel Baluta @ 2013-07-19 16:29 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Alexandru Juncu, Pekka Enberg, andreas.dilger, tao.peng,
driverdev, LKML, pebolle
On Fri, Jul 19, 2013 at 6:46 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Fri, Jul 19, 2013 at 06:29:34PM +0300, Alexandru Juncu wrote:
>> On 19 July 2013 18:21, Pekka Enberg <penberg@kernel.org> wrote:
>> > On Fri, Jul 19, 2013 at 6:13 PM, Alexandru Juncu <alexj@rosedu.org> wrote:
>> >> 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.
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.
^ permalink raw reply [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.