]> git.karo-electronics.de Git - linux-beck.git/commitdiff
wireless: fix bogus maybe-uninitialized warning
authorArnd Bergmann <arnd@arndb.de>
Mon, 24 Oct 2016 15:38:35 +0000 (17:38 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 17 Nov 2016 06:46:38 +0000 (08:46 +0200)
The hostap_80211_rx() function is supposed to set up the mac addresses
for four possible cases, based on two bits of input data. For
some reason, gcc decides that it's possible that none of the these
four cases apply and the addresses remain uninitialized:

drivers/net/wireless/intersil/hostap/hostap_80211_rx.c: In function ‘hostap_80211_rx’:
arch/x86/include/asm/string_32.h:77:14: warning: ‘src’ may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/net/wireless/intel/ipw2x00/libipw_rx.c: In function ‘libipw_rx’:
arch/x86/include/asm/string_32.h:77:14: error: ‘dst’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
arch/x86/include/asm/string_32.h:78:22: error: ‘*((void *)&dst+4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

This warning is clearly nonsense, but changing the last case into
'default' makes it obvious to the compiler too, which avoids the
warning and probably leads to better object code too.

The same code is duplicated several times in the kernel, so this
patch uses the same workaround for all copies. The exact configuration
was hit only very rarely in randconfig builds and I only saw it
in three drivers, but I assume that all of them are potentially
affected, and it's better to keep the code consistent.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath6kl/wmi.c
drivers/net/wireless/intel/ipw2x00/libipw_rx.c
drivers/net/wireless/intersil/hostap/hostap_80211_rx.c
net/wireless/lib80211_crypt_tkip.c

index 3fd1cc98fd2fafa52e8fb6f941084bb84dec50a6..84a6d12c3f8a3b45c8940dfe2eac53bee9274f3e 100644 (file)
@@ -421,10 +421,6 @@ int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb)
 
        switch ((le16_to_cpu(wh.frame_control)) &
                (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
-       case 0:
-               memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
-               memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
-               break;
        case IEEE80211_FCTL_TODS:
                memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN);
                memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
@@ -435,6 +431,10 @@ int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb)
                break;
        case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
                break;
+       default:
+               memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
+               memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
+               break;
        }
 
        skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr));
index cef7f7d79cd9278e37a83ef0306254cf6fa138ad..1c1ec7bb93023567f63e01e386076b1d20f1b326 100644 (file)
@@ -507,7 +507,7 @@ int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
                memcpy(dst, hdr->addr3, ETH_ALEN);
                memcpy(src, hdr->addr4, ETH_ALEN);
                break;
-       case 0:
+       default:
                memcpy(dst, hdr->addr1, ETH_ALEN);
                memcpy(src, hdr->addr2, ETH_ALEN);
                break;
index 599f30f22841f9e665a485f675ad449d105c448a..34dbddbf3f9b1d74eed812df8feb95767da07a6f 100644 (file)
@@ -855,7 +855,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
                memcpy(dst, hdr->addr3, ETH_ALEN);
                memcpy(src, hdr->addr4, ETH_ALEN);
                break;
-       case 0:
+       default:
                memcpy(dst, hdr->addr1, ETH_ALEN);
                memcpy(src, hdr->addr2, ETH_ALEN);
                break;
index 71447cf863067ca7be13b7c0b5011a44a3645b49..ba0a1f398ce580a978a9d2e4ccd366cb5b644738 100644 (file)
@@ -556,7 +556,7 @@ static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr)
                memcpy(hdr, hdr11->addr3, ETH_ALEN);    /* DA */
                memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
                break;
-       case 0:
+       default:
                memcpy(hdr, hdr11->addr1, ETH_ALEN);    /* DA */
                memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
                break;