2015-07-08 19:40:36

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH] mac80211: Use kstrdup to simplify code

Replace a kmalloc+strcpy by an equivalent kstrdup in order to improve
readability.

Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 4813506..8a6c077 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -1476,9 +1476,7 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
wl->timers = t;

#ifdef DEBUG
- t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC);
- if (t->name)
- strcpy(t->name, name);
+ t->name = kstrdup(name, GFP_ATOMIC);
#endif

return t;
--
2.1.4



2015-07-08 19:53:53

by Emmanuel Grumbach

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Use kstrdup to simplify code

The subject is wrong. You are not patch mac80211, but bcrmsmac.

On Wed, Jul 8, 2015 at 10:32 PM, Christophe JAILLET
<[email protected]> wrote:
> Replace a kmalloc+strcpy by an equivalent kstrdup in order to improve
> readability.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
> index 4813506..8a6c077 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
> @@ -1476,9 +1476,7 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
> wl->timers = t;
>
> #ifdef DEBUG
> - t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC);
> - if (t->name)
> - strcpy(t->name, name);
> + t->name = kstrdup(name, GFP_ATOMIC);
> #endif
>
> return t;
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2015-07-08 20:23:10

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH v2] brcmsmac: Use kstrdup to simplify code

Replace a kmalloc+strcpy by an equivalent kstrdup in order to improve
readability.

Signed-off-by: Christophe JAILLET <[email protected]>
---
v2: fix the subject

drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 4813506..8a6c077 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -1476,9 +1476,7 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
wl->timers = t;

#ifdef DEBUG
- t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC);
- if (t->name)
- strcpy(t->name, name);
+ t->name = kstrdup(name, GFP_ATOMIC);
#endif

return t;
--
2.1.4


2015-07-21 14:59:55

by Kalle Valo

[permalink] [raw]
Subject: Re: [v2] brcmsmac: Use kstrdup to simplify code


> Replace a kmalloc+strcpy by an equivalent kstrdup in order to improve
> readability.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> Acked-by: Arend van Spriel <[email protected]>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

2015-07-09 18:36:44

by Arend van Spriel

[permalink] [raw]
Subject: Re: [PATCH v2] brcmsmac: Use kstrdup to simplify code

On 07/08/2015 10:22 PM, Christophe JAILLET wrote:
> Replace a kmalloc+strcpy by an equivalent kstrdup in order to improve
> readability.

Not sure if readability is really the issue here. At most it is a small
reduction of driver code by using kstrdup(). Anyway, the patch looks fine so

Acked-by: Arend van Spriel <[email protected]>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> v2: fix the subject
>
> drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
> index 4813506..8a6c077 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
> @@ -1476,9 +1476,7 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
> wl->timers = t;
>
> #ifdef DEBUG
> - t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC);
> - if (t->name)
> - strcpy(t->name, name);
> + t->name = kstrdup(name, GFP_ATOMIC);
> #endif
>
> return t;
>