From 6f9d3832bf615e2fa5817057de8c5697c9f07018 Mon Sep 17 00:00:00 2001 From: Christophe Jaillet Date: Wed, 31 Aug 2016 13:50:59 +0200 Subject: [PATCH 10/13] UPSTREAM: mwifiex: scan: Simplify code 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 Signed-off-by: Kalle Valo (cherry picked from commit b711657616947e7b4c15f6825d259324216b23f2) BUG=b:36466135 TEST=check wifi still works on kevin Change-Id: I9ab79bd2a02bb1ccb54f8d49eb56102ec21e36c8 Signed-off-by: Jeffy Chen Reviewed-on: https://chromium-review.googlesource.com/462178 Commit-Ready: Brian Norris Tested-by: Brian Norris Reviewed-by: Brian Norris --- drivers/net/wireless/mwifiex/scan.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index cabc97d491a2..a98148b0465b 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -2158,18 +2158,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; - } + if (pmatch) { + pmatch->n_channels = 1; + pmatch->channels[0] = chan_band->chan_number; } } -- 2.13.3