staging: rtl8192x: fix bogus maybe-uninitialized warning
authorArnd Bergmann <arnd@arndb.de>
Mon, 24 Oct 2016 15:38:34 +0000 (17:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Oct 2016 07:40:44 +0000 (09:40 +0200)
The rtllib_rx_extract_addr() 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/staging/rtl8192e/rtllib_rx.c: In function ‘rtllib_rx_InfraAdhoc’:
include/linux/etherdevice.h:316:61: error: ‘*((void *)&dst+4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/staging/rtl8192e/rtllib_rx.c:1318:5: note: ‘*((void *)&dst+4)’ was declared here
ded from /git/arm-soc/drivers/staging/rtl8192e/rtllib_rx.c:40:0:
include/linux/etherdevice.h:316:36: error: ‘dst’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/staging/rtl8192e/rtllib_rx.c:1318:5: note: ‘dst’ was declared here

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.

As the same warning appears in other files that have the exact
same code, I'm fixing it in both rtl8192e and rtl8192u, even
though I did not observe it for the latter.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192e/rtllib_rx.c
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c

index c743182b933e65d79d938fcca0d136507b18c014..d6777ecda64d866feee1ed95d2cd6061ca6fd1b8 100644 (file)
@@ -986,7 +986,7 @@ static void rtllib_rx_extract_addr(struct rtllib_device *ieee,
                ether_addr_copy(src, hdr->addr4);
                ether_addr_copy(bssid, ieee->current_network.bssid);
                break;
-       case 0:
+       default:
                ether_addr_copy(dst, hdr->addr1);
                ether_addr_copy(src, hdr->addr2);
                ether_addr_copy(bssid, hdr->addr3);
index 6fa96d57d31629aebfd49ec81cd6f13e0f46cf81..e68850897adf8a8656d1c96ea3b139364282f121 100644 (file)
@@ -553,7 +553,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;
index 89cbc077a48d896b016df1bc3ed29336ca6ef10d..2e4d2d7bc2e7a22693e53695a86de30ca1527c7b 100644 (file)
@@ -1079,7 +1079,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                memcpy(src, hdr->addr4, ETH_ALEN);
                memcpy(bssid, ieee->current_network.bssid, ETH_ALEN);
                break;
-       case 0:
+       default:
                memcpy(dst, hdr->addr1, ETH_ALEN);
                memcpy(src, hdr->addr2, ETH_ALEN);
                memcpy(bssid, hdr->addr3, ETH_ALEN);