]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: rtl8188eu: Simplify memcmp logical checks
authorNathan Chancellor <natechancellor@gmail.com>
Tue, 25 Sep 2018 19:13:26 +0000 (12:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 28 Sep 2018 12:30:51 +0000 (14:30 +0200)
Clang generates a warning when it sees a logical not followed by a
conditional operator like ==, >, or < because it thinks that the logical
not should be applied to the whole statement:

drivers/staging/rtl8188eu/core/rtw_ieee80211.c:293:8: warning: logical
not is only applied to the left hand side of this comparison
[-Wlogical-not-parentheses]

It assumes the author might have made a mistake in their logic:

if (!a == b) -> if (!(a == b))

Sometimes that is the case; other times, it's just a super convoluted
way of saying 'if (a)' when b = 0:

if (!1 == 0) -> if (0 == 0) -> if (true)

Alternatively:

if (!1 == 0) -> if (!!1) -> if (1)

Simplify these comparisons so that Clang doesn't complain.

Link: https://github.com/ClangBuiltLinux/linux/issues/161
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8188eu/core/rtw_ieee80211.c
drivers/staging/rtl8188eu/core/rtw_mlme.c
drivers/staging/rtl8188eu/core/rtw_recv.c
drivers/staging/rtl8188eu/core/rtw_wlan_util.c

index 9e5c7e62d26f550bf88136d67d696c782b2ec71b..20f34d25c369915ad9afb5653bad8790059f1624 100644 (file)
@@ -284,7 +284,7 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, uint *wpa_ie_len, int limit)
 
                if (pbuf) {
                        /* check if oui matches... */
-                       if (!memcmp((pbuf + 2), wpa_oui_type, sizeof(wpa_oui_type)) == false)
+                       if (memcmp((pbuf + 2), wpa_oui_type, sizeof(wpa_oui_type)))
                                goto check_next_ie;
 
                        /* check version... */
index 3d9c293a72d984b761c880e8c47f8557de5f50fc..d18d34313a9ed6199177d159ea9364d857f6dffb 100644 (file)
@@ -1414,7 +1414,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv
        /* check ssid, if needed */
        if (pmlmepriv->assoc_ssid.SsidLength) {
                if (competitor->network.Ssid.SsidLength != pmlmepriv->assoc_ssid.SsidLength ||
-                   !memcmp(competitor->network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength) == false)
+                   memcmp(competitor->network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength))
                        goto exit;
        }
 
index ab9638d618a9820727cb9a8ec13a76d5ccc194c1..f3eb63f8cf0bbc813fa9981d98433bc21e39b3be 100644 (file)
@@ -1283,8 +1283,8 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe)
        psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE;
        /* convert hdr + possible LLC headers into Ethernet header */
        if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) &&
-            (!memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) == false) &&
-            (!memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2) == false)) ||
+            memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) &&
+            memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2)) ||
             !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) {
                /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
                bsnaphdr = true;
index fb496ab5a86221522cda6fbe417dca74ef7015a9..53fac22ff621ef020644e29c07677cc0fcf6e609 100644 (file)
@@ -856,7 +856,7 @@ int rtw_check_bcn_info(struct adapter  *Adapter, u8 *pframe, u32 packet_len)
                return _FAIL;
        }
 
-       if (!memcmp(cur_network->network.MacAddress, pbssid, 6) == false) {
+       if (memcmp(cur_network->network.MacAddress, pbssid, 6)) {
                DBG_88E("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n%pM %pM\n",
                        (pbssid), (cur_network->network.MacAddress));
                return true;