From patchwork Mon Aug 10 16:05:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "John W. Linville" X-Patchwork-Id: 6985571 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3FDAA9F358 for ; Mon, 10 Aug 2015 16:15:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56EA320627 for ; Mon, 10 Aug 2015 16:15:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 68F6E20620 for ; Mon, 10 Aug 2015 16:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754924AbbHJQPT (ORCPT ); Mon, 10 Aug 2015 12:15:19 -0400 Received: from charlotte.tuxdriver.com ([70.61.120.58]:58299 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753876AbbHJQPQ (ORCPT ); Mon, 10 Aug 2015 12:15:16 -0400 Received: from uucp by smtp.tuxdriver.com with local-rmail (Exim 4.63) (envelope-from ) id 1ZOpjD-0001I8-Hz; Mon, 10 Aug 2015 12:15:11 -0400 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.15.1/8.14.6) with ESMTP id t7AG5f0e024619; Mon, 10 Aug 2015 12:05:41 -0400 Received: (from linville@localhost) by localhost.localdomain (8.15.1/8.15.1/Submit) id t7AG5eeu024601; Mon, 10 Aug 2015 12:05:40 -0400 From: "John W. Linville" To: linux-wireless@vger.kernel.org Cc: Kalle Valo , Lennert Buytenhek , "John W. Linville" Subject: [PATCH] mwl8k: refactor some conditionals for clarity Date: Mon, 10 Aug 2015 12:05:39 -0400 Message-Id: <1439222739-24545-1-git-send-email-linville@tuxdriver.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP CC [M] drivers/net/wireless/mwl8k.o drivers/net/wireless/mwl8k.c: In function ‘mwl8k_bss_info_changed’: drivers/net/wireless/mwl8k.c:3290:2: warning: ‘ap_mcs_rates’ may be used uninitialized in this function [-Wmaybe-uninitialized] memcpy(cmd->mcs_set, mcs_rates, 16); ^ drivers/net/wireless/mwl8k.c:4987:5: note: ‘ap_mcs_rates’ was declared here u8 ap_mcs_rates[16]; ^ The warning was bogus. But the conditionals were rather complicated, with multiple redundant checks. This consolidates the checking and makes it more readable IMHO. Signed-off-by: John W. Linville --- Compile tested only. Sorry for any duplicates -- I sent the first one to the wrong list address! drivers/net/wireless/mwl8k.c | 49 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c index 77361af68b18..9420fc61c2e6 100644 --- a/drivers/net/wireless/mwl8k.c +++ b/drivers/net/wireless/mwl8k.c @@ -5019,35 +5019,36 @@ mwl8k_bss_info_changed_sta(struct ieee80211_hw *hw, struct ieee80211_vif *vif, memcpy(ap_mcs_rates, ap->ht_cap.mcs.rx_mask, 16); rcu_read_unlock(); - } - if ((changed & BSS_CHANGED_ASSOC) && vif->bss_conf.assoc && - !priv->ap_fw) { - rc = mwl8k_cmd_set_rate(hw, vif, ap_legacy_rates, ap_mcs_rates); - if (rc) - goto out; + if (changed & BSS_CHANGED_ASSOC) { + if (!priv->ap_fw) { + rc = mwl8k_cmd_set_rate(hw, vif, + ap_legacy_rates, + ap_mcs_rates); + if (rc) + goto out; - rc = mwl8k_cmd_use_fixed_rate_sta(hw); - if (rc) - goto out; - } else { - if ((changed & BSS_CHANGED_ASSOC) && vif->bss_conf.assoc && - priv->ap_fw) { - int idx; - int rate; + rc = mwl8k_cmd_use_fixed_rate_sta(hw); + if (rc) + goto out; + } else { + int idx; + int rate; - /* Use AP firmware specific rate command. - */ - idx = ffs(vif->bss_conf.basic_rates); - if (idx) - idx--; + /* Use AP firmware specific rate command. + */ + idx = ffs(vif->bss_conf.basic_rates); + if (idx) + idx--; - if (hw->conf.chandef.chan->band == IEEE80211_BAND_2GHZ) - rate = mwl8k_rates_24[idx].hw_value; - else - rate = mwl8k_rates_50[idx].hw_value; + if (hw->conf.chandef.chan->band == + IEEE80211_BAND_2GHZ) + rate = mwl8k_rates_24[idx].hw_value; + else + rate = mwl8k_rates_50[idx].hw_value; - mwl8k_cmd_use_fixed_rate_ap(hw, rate, rate); + mwl8k_cmd_use_fixed_rate_ap(hw, rate, rate); + } } }