From patchwork Thu Mar 10 08:44:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Fenkart X-Patchwork-Id: 8554441 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0A3CBC0553 for ; Thu, 10 Mar 2016 08:44:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8A18202FF for ; Thu, 10 Mar 2016 08:44:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94A1B202FE for ; Thu, 10 Mar 2016 08:44:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754582AbcCJIoV (ORCPT ); Thu, 10 Mar 2016 03:44:21 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:38839 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932742AbcCJIoT (ORCPT ); Thu, 10 Mar 2016 03:44:19 -0500 Received: by mail-wm0-f43.google.com with SMTP id l68so18499162wml.1 for ; Thu, 10 Mar 2016 00:44:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PEYc9+Zyn2JWgk37hbL3JgVSKOLRduQeTXUHWRvEdh0=; b=q0aUZuruWLnF9KvtlDgeeOIRxNYsDxjD37jyH4lYy3WHPnF/QUtQfgacphJyazhcVp bOFfO9L50aV8rVqABiBNJYCEvPPNx60xv+NOSPx4NrK219da5uQQXIXfjxGcYyxXQNyk a5xOF7xtg8AUrK9JWLcpUVuU/yI6lq0wLq5qUL9hXMeDy4ZFCHH8n4C/FN1Cnj/urcBj ZTl9YwTDq0OGDxEE+U7NJeM9ljzmgoTNBv4qz6tTCcKP2eeFnwS5mzuyYCYXs+yzq5E3 ZhoySf7sREIZ8WHz7LT8QxPAaJMt8jLUl9qt2uFpU4VrB/1y03yvFdlbBcc/1HYwd/Zx KHVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PEYc9+Zyn2JWgk37hbL3JgVSKOLRduQeTXUHWRvEdh0=; b=hCYkg25gXi5nU+TB0lONZjz+ar5RbXE9uBC8Cu7jEbkLTBUDFnLj/N2BeOt1IzTKSx lKrW1GMLMq9zbjRVlxWad2OzQhCYeFnfXpybua3MR6Z9BLVrwG/sq5YOjBvWB4kf79LI PcS6KWZufy+c8rn0Fz8cyKSwUFlgT4UhkqmMstqIeOVg+5fHeiOLK8SHKpxTddwLsstr 3n+mdSF10clucxZa0KiXMwRDLWb+dtR0LtQC802n8ukj82cLiI2ZSJsRgru5LzNxctwS 5CbNNuWaj4f4ry69ic05fWmZ1Ff1eP2bkA70HY7XwXxlA1qV3nWvafpWzpdGPuPGM7R1 y9kg== X-Gm-Message-State: AD7BkJKVIxrBysVYx6i3WTzw/PeMZ+JUUbaBMI3xURvEZ4GwXV35TUXH5nRWW34UDpossA== X-Received: by 10.194.95.40 with SMTP id dh8mr2547070wjb.146.1457599458361; Thu, 10 Mar 2016 00:44:18 -0800 (PST) Received: from localhost (ip-89-176-167-254.net.upcbroadband.cz. [89.176.167.254]) by smtp.gmail.com with ESMTPSA id d2sm2354344wjf.28.2016.03.10.00.44.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Mar 2016 00:44:17 -0800 (PST) From: Andreas Fenkart To: linux-wireless@vger.kernel.org Cc: Amitkumar Karwar , Nishant Sarmukadam , Julian Calaby , Kalle Valo , Andreas Fenkart Subject: [PATCH v2 1/7] mwifiex: scan: simplify dereference of bss_desc fields Date: Thu, 10 Mar 2016 09:44:05 +0100 Message-Id: <1457599451-13910-2-git-send-email-afenkart@gmail.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1457599451-13910-1-git-send-email-afenkart@gmail.com> References: <1457599451-13910-1-git-send-email-afenkart@gmail.com> 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 given this structure: struct foo { struct bar { int baz; } } these accesses are equivalent: (*(foo->bar)).baz foo->bar->baz Signed-off-by: Andreas Fenkart --- drivers/net/wireless/marvell/mwifiex/scan.c | 98 ++++++++++++++--------------- 1 file changed, 46 insertions(+), 52 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c index c20017c..a7bdde5 100644 --- a/drivers/net/wireless/marvell/mwifiex/scan.c +++ b/drivers/net/wireless/marvell/mwifiex/scan.c @@ -121,8 +121,8 @@ mwifiex_is_rsn_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher) struct ie_body *iebody; u8 ret = MWIFIEX_OUI_NOT_PRESENT; - if (((bss_desc->bcn_rsn_ie) && ((*(bss_desc->bcn_rsn_ie)). - ieee_hdr.element_id == WLAN_EID_RSN))) { + if (bss_desc->bcn_rsn_ie && + bss_desc->bcn_rsn_ie->ieee_hdr.element_id == WLAN_EID_RSN) { iebody = (struct ie_body *) (((u8 *) bss_desc->bcn_rsn_ie->data) + RSN_GTK_OUI_OFFSET); @@ -148,9 +148,9 @@ mwifiex_is_wpa_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher) struct ie_body *iebody; u8 ret = MWIFIEX_OUI_NOT_PRESENT; - if (((bss_desc->bcn_wpa_ie) && - ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id == - WLAN_EID_VENDOR_SPECIFIC))) { + if (bss_desc->bcn_wpa_ie && + bss_desc->bcn_wpa_ie->vend_hdr.element_id == + WLAN_EID_VENDOR_SPECIFIC) { iebody = (struct ie_body *) bss_desc->bcn_wpa_ie->data; oui = &mwifiex_wpa_oui[cipher][0]; ret = mwifiex_search_oui_in_ie(iebody, oui); @@ -181,8 +181,8 @@ mwifiex_is_bss_wapi(struct mwifiex_private *priv, { if (priv->sec_info.wapi_enabled && (bss_desc->bcn_wapi_ie && - ((*(bss_desc->bcn_wapi_ie)).ieee_hdr.element_id == - WLAN_EID_BSS_AC_ACCESS_DELAY))) { + bss_desc->bcn_wapi_ie->ieee_hdr.element_id == + WLAN_EID_BSS_AC_ACCESS_DELAY)) { return true; } return false; @@ -197,12 +197,12 @@ mwifiex_is_bss_no_sec(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && - !priv->sec_info.wpa2_enabled && ((!bss_desc->bcn_wpa_ie) || - ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != - WLAN_EID_VENDOR_SPECIFIC)) && - ((!bss_desc->bcn_rsn_ie) || - ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id != - WLAN_EID_RSN)) && + !priv->sec_info.wpa2_enabled && + (!bss_desc->bcn_wpa_ie || + bss_desc->bcn_wpa_ie->vend_hdr.element_id != + WLAN_EID_VENDOR_SPECIFIC) && + (!bss_desc->bcn_rsn_ie || + bss_desc->bcn_rsn_ie->ieee_hdr.element_id != WLAN_EID_RSN) && !priv->sec_info.encryption_mode && !bss_desc->privacy) { return true; } @@ -233,9 +233,10 @@ mwifiex_is_bss_wpa(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { if (!priv->sec_info.wep_enabled && priv->sec_info.wpa_enabled && - !priv->sec_info.wpa2_enabled && ((bss_desc->bcn_wpa_ie) && - ((*(bss_desc->bcn_wpa_ie)). - vend_hdr.element_id == WLAN_EID_VENDOR_SPECIFIC)) + !priv->sec_info.wpa2_enabled && + (bss_desc->bcn_wpa_ie && + bss_desc->bcn_wpa_ie->vend_hdr.element_id == + WLAN_EID_VENDOR_SPECIFIC) /* * Privacy bit may NOT be set in some APs like * LinkSys WRT54G && bss_desc->privacy @@ -245,12 +246,10 @@ mwifiex_is_bss_wpa(struct mwifiex_private *priv, "info: %s: WPA:\t" "wpa_ie=%#x wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s\t" "EncMode=%#x privacy=%#x\n", __func__, - (bss_desc->bcn_wpa_ie) ? - (*bss_desc->bcn_wpa_ie). - vend_hdr.element_id : 0, - (bss_desc->bcn_rsn_ie) ? - (*bss_desc->bcn_rsn_ie). - ieee_hdr.element_id : 0, + bss_desc->bcn_wpa_ie ? + bss_desc->bcn_wpa_ie->vend_hdr.element_id : 0, + bss_desc->bcn_rsn_ie ? + bss_desc->bcn_rsn_ie->ieee_hdr.element_id : 0, (priv->sec_info.wep_enabled) ? "e" : "d", (priv->sec_info.wpa_enabled) ? "e" : "d", (priv->sec_info.wpa2_enabled) ? "e" : "d", @@ -269,11 +268,10 @@ static bool mwifiex_is_bss_wpa2(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { - if (!priv->sec_info.wep_enabled && - !priv->sec_info.wpa_enabled && + if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && priv->sec_info.wpa2_enabled && - ((bss_desc->bcn_rsn_ie) && - ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id == WLAN_EID_RSN))) { + (bss_desc->bcn_rsn_ie && + bss_desc->bcn_rsn_ie->ieee_hdr.element_id == WLAN_EID_RSN)) { /* * Privacy bit may NOT be set in some APs like * LinkSys WRT54G && bss_desc->privacy @@ -282,12 +280,10 @@ mwifiex_is_bss_wpa2(struct mwifiex_private *priv, "info: %s: WPA2:\t" "wpa_ie=%#x wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s\t" "EncMode=%#x privacy=%#x\n", __func__, - (bss_desc->bcn_wpa_ie) ? - (*bss_desc->bcn_wpa_ie). - vend_hdr.element_id : 0, - (bss_desc->bcn_rsn_ie) ? - (*bss_desc->bcn_rsn_ie). - ieee_hdr.element_id : 0, + bss_desc->bcn_wpa_ie ? + bss_desc->bcn_wpa_ie->vend_hdr.element_id : 0, + bss_desc->bcn_rsn_ie ? + bss_desc->bcn_rsn_ie->ieee_hdr.element_id : 0, (priv->sec_info.wep_enabled) ? "e" : "d", (priv->sec_info.wpa_enabled) ? "e" : "d", (priv->sec_info.wpa2_enabled) ? "e" : "d", @@ -308,11 +304,11 @@ mwifiex_is_bss_adhoc_aes(struct mwifiex_private *priv, { if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled && - ((!bss_desc->bcn_wpa_ie) || - ((*(bss_desc->bcn_wpa_ie)). - vend_hdr.element_id != WLAN_EID_VENDOR_SPECIFIC)) && - ((!bss_desc->bcn_rsn_ie) || - ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id != WLAN_EID_RSN)) && + (!bss_desc->bcn_wpa_ie || + bss_desc->bcn_wpa_ie->vend_hdr.element_id != + WLAN_EID_VENDOR_SPECIFIC) && + (!bss_desc->bcn_rsn_ie || + bss_desc->bcn_rsn_ie->ieee_hdr.element_id != WLAN_EID_RSN) && !priv->sec_info.encryption_mode && bss_desc->privacy) { return true; } @@ -329,23 +325,21 @@ mwifiex_is_bss_dynamic_wep(struct mwifiex_private *priv, { if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled && - ((!bss_desc->bcn_wpa_ie) || - ((*(bss_desc->bcn_wpa_ie)). - vend_hdr.element_id != WLAN_EID_VENDOR_SPECIFIC)) && - ((!bss_desc->bcn_rsn_ie) || - ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id != WLAN_EID_RSN)) && + (!bss_desc->bcn_wpa_ie || + bss_desc->bcn_wpa_ie->vend_hdr.element_id != + WLAN_EID_VENDOR_SPECIFIC) && + (!bss_desc->bcn_rsn_ie || + bss_desc->bcn_rsn_ie->ieee_hdr.element_id != WLAN_EID_RSN) && priv->sec_info.encryption_mode && bss_desc->privacy) { mwifiex_dbg(priv->adapter, INFO, "info: %s: dynamic\t" "WEP: wpa_ie=%#x wpa2_ie=%#x\t" "EncMode=%#x privacy=%#x\n", __func__, - (bss_desc->bcn_wpa_ie) ? - (*bss_desc->bcn_wpa_ie). - vend_hdr.element_id : 0, - (bss_desc->bcn_rsn_ie) ? - (*bss_desc->bcn_rsn_ie). - ieee_hdr.element_id : 0, + bss_desc->bcn_wpa_ie ? + bss_desc->bcn_wpa_ie->vend_hdr.element_id : 0, + bss_desc->bcn_rsn_ie ? + bss_desc->bcn_rsn_ie->ieee_hdr.element_id : 0, priv->sec_info.encryption_mode, bss_desc->privacy); return true; @@ -464,10 +458,10 @@ mwifiex_is_network_compatible(struct mwifiex_private *priv, "info: %s: failed: wpa_ie=%#x wpa2_ie=%#x WEP=%s\t" "WPA=%s WPA2=%s EncMode=%#x privacy=%#x\n", __func__, - (bss_desc->bcn_wpa_ie) ? - (*bss_desc->bcn_wpa_ie).vend_hdr.element_id : 0, - (bss_desc->bcn_rsn_ie) ? - (*bss_desc->bcn_rsn_ie).ieee_hdr.element_id : 0, + bss_desc->bcn_wpa_ie ? + bss_desc->bcn_wpa_ie->vend_hdr.element_id : 0, + bss_desc->bcn_rsn_ie ? + bss_desc->bcn_rsn_ie->ieee_hdr.element_id : 0, (priv->sec_info.wep_enabled) ? "e" : "d", (priv->sec_info.wpa_enabled) ? "e" : "d", (priv->sec_info.wpa2_enabled) ? "e" : "d",