From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964917AbcHaPJW (ORCPT ); Wed, 31 Aug 2016 11:09:22 -0400 Received: from smtprelay0213.hostedemail.com ([216.40.44.213]:33575 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935178AbcHaPJU (ORCPT ); Wed, 31 Aug 2016 11:09:20 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2828:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3870:3871:3872:3874:4250:4321:5007:7875:10004:10400:10848:11026:11232:11473:11657:11658:11783:11914:12043:12048:12296:12438:12555:12740:13069:13311:13357:13439:13894:14181:14659:14721:21080:21451:30012:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: lace35_161e405a5dc27 X-Filterd-Recvd-Size: 2782 Message-ID: <1472656150.4176.7.camel@perches.com> Subject: Re: [PATCH] mwifiex: scan: Simplify code From: Joe Perches To: Christophe JAILLET , akarwar@marvell.com, nishants@marvell.com, kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Date: Wed, 31 Aug 2016 08:09:10 -0700 In-Reply-To: <1472644259-15605-1-git-send-email-christophe.jaillet@wanadoo.fr> References: <1472644259-15605-1-git-send-email-christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.