* [PATCH] mwifiex: scan: Simplify code
@ 2016-08-31 11:50 Christophe JAILLET
2016-08-31 15:09 ` Joe Perches
2016-09-09 9:21 ` Kalle Valo
0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2016-08-31 11:50 UTC (permalink / raw)
To: akarwar, nishants, kvalo
Cc: linux-wireless, netdev, linux-kernel, kernel-janitors,
Christophe JAILLET
This patch:
- improves code layout
- removes a useless memset(0) for some memory allocated with kzalloc
- removes a useless if. We know that 'if (chan_band_tlv)' will succeed
because it has been tested a few lines above
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/net/wireless/marvell/mwifiex/scan.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
index 21ec84794d0c..c29dd958acae 100644
--- a/drivers/net/wireless/marvell/mwifiex/scan.c
+++ b/drivers/net/wireless/marvell/mwifiex/scan.c
@@ -2179,18 +2179,14 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
if (chan_band_tlv && adapter->nd_info) {
adapter->nd_info->matches[idx] =
- kzalloc(sizeof(*pmatch) +
- sizeof(u32), GFP_ATOMIC);
+ kzalloc(sizeof(*pmatch) + sizeof(u32),
+ GFP_ATOMIC);
pmatch = adapter->nd_info->matches[idx];
if (pmatch) {
- memset(pmatch, 0, sizeof(*pmatch));
- if (chan_band_tlv) {
- pmatch->n_channels = 1;
- pmatch->channels[0] =
- chan_band->chan_number;
- }
+ pmatch->n_channels = 1;
+ pmatch->channels[0] = chan_band->chan_number;
}
}
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mwifiex: scan: Simplify code
2016-08-31 11:50 [PATCH] mwifiex: scan: Simplify code Christophe JAILLET
@ 2016-08-31 15:09 ` Joe Perches
2016-09-09 9:21 ` Kalle Valo
1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2016-08-31 15:09 UTC (permalink / raw)
To: Christophe JAILLET, akarwar, nishants, kvalo
Cc: linux-wireless, netdev, linux-kernel, kernel-janitors
On Wed, 2016-08-31 at 13:50 +0200, Christophe JAILLET wrote:
> This patch:
> - improves code layout
> - removes a useless memset(0) for some memory allocated with kzalloc
> - removes a useless if. We know that 'if (chan_band_tlv)' will succeed
> because it has been tested a few lines above
True, the code above it is also confusing as it's
#ifdef CONFIG_PM
if (priv->wdev.wiphy->wowlan_config)
nd_config = priv->wdev.wiphy->wowlan_config->nd_config;
#endif
if (nd_config) {
adapter->nd_info =
kzalloc(sizeof(struct cfg80211_wowlan_nd_match) +
sizeof(struct cfg80211_wowlan_nd_match *) *
scan_rsp->number_of_sets, GFP_ATOMIC);
if (adapter->nd_info)
adapter->nd_info->n_matches = scan_rsp->number_of_sets;
}
where nd_config is a pointer already initialized to NULL
so the #endif seems misplaced.
> diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
[]
> @@ -2179,18 +2179,14 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
>
> if (chan_band_tlv && adapter->nd_info) {
> adapter->nd_info->matches[idx] =
> - kzalloc(sizeof(*pmatch) +
> - sizeof(u32), GFP_ATOMIC);
> + kzalloc(sizeof(*pmatch) + sizeof(u32),
> + GFP_ATOMIC);
>
> pmatch = adapter->nd_info->matches[idx];
>
> if (pmatch) {
> - memset(pmatch, 0, sizeof(*pmatch));
> - if (chan_band_tlv) {
> - pmatch->n_channels = 1;
> - pmatch->channels[0] =
> - chan_band->chan_number;
> - }
> + pmatch->n_channels = 1;
> + pmatch->channels[0] = chan_band->chan_number;
> }
> }
Maybe it'd be better to move the pmatch declaration to this block
and alloc to pmatch then assign adapter->nd_info->matches[idx]
later.
I think the #ifdef CONFIG_PM use in this routine is incomplete.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: mwifiex: scan: Simplify code
2016-08-31 11:50 [PATCH] mwifiex: scan: Simplify code Christophe JAILLET
2016-08-31 15:09 ` Joe Perches
@ 2016-09-09 9:21 ` Kalle Valo
1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2016-09-09 9:21 UTC (permalink / raw)
To: Christophe Jaillet
Cc: akarwar, nishants, linux-wireless, netdev, linux-kernel,
kernel-janitors, Christophe JAILLET
Christophe Jaillet <christophe.jaillet@wanadoo.fr> wrote:
> This patch:
> - improves code layout
> - removes a useless memset(0) for some memory allocated with kzalloc
> - removes a useless if. We know that 'if (chan_band_tlv)' will succeed
> because it has been tested a few lines above
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Thanks, 1 patch applied to wireless-drivers-next.git:
b71165761694 mwifiex: scan: Simplify code
--
Sent by pwcli
https://patchwork.kernel.org/patch/9307009/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-09 9:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-31 11:50 [PATCH] mwifiex: scan: Simplify code Christophe JAILLET
2016-08-31 15:09 ` Joe Perches
2016-09-09 9:21 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).