staging: rtl8192x: fix bogus maybe-uninitialized warning
Subsystems (7)
PATCH 1/1 staging: rtl8192x: fix bogus maybe-uninitialized warning
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.
--- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rtl8192e/rtllib_rx.c +1 -1
@@ -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);
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c +1 -1
@@ -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 ;
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +1 -1
@@ -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 );
Signature · 6 lines
2.9.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 1/1 wireless: fix bogus maybe-uninitialized warning
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.
--- drivers/net/wireless/ath/ath6kl/wmi.c | 8 ++++---- drivers/net/wireless/intel/ipw2x00/libipw_rx.c | 2 +- drivers/net/wireless/intersil/hostap/hostap_80211_rx.c | 2 +- net/wireless/lib80211_crypt_tkip.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath6kl/wmi.c +4 -4
@@ -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 ));
drivers/net/wireless/intel/ipw2x00/libipw_rx.c +1 -1
@@ -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 ;
drivers/net/wireless/intersil/hostap/hostap_80211_rx.c +1 -1
@@ -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 ;
net/wireless/lib80211_crypt_tkip.c +1 -1
@@ -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 ;
Signature · 1 line
2.9.0
Re: [PATCH] wireless: fix bogus maybe-uninitialized warning
Quoted 6 lines · Arnd Bergmann
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 =E2=
=80=98hostap_80211_rx=E2=80=99:
Quoted 1 line
arch/x86/include/asm/string_32.h:77:14: warning: =E2=80=98src=E2=80=99 ma=
y be used uninitialized in this function [-Wmaybe-uninitialized]
Quoted 1 line
drivers/net/wireless/intel/ipw2x00/libipw_rx.c: In function =E2=80=98libi=
pw_rx=E2=80=99:
Quoted 1 line
arch/x86/include/asm/string_32.h:77:14: error: =E2=80=98dst=E2=80=99 may =
be used uninitialized in this function [-Werror=3Dmaybe-uninitialized]
Quoted 1 line
arch/x86/include/asm/string_32.h:78:22: error: =E2=80=98*((void *)&dst+4)=
=E2=80=99 may be used uninitialized in this function [-Werror=3Dmaybe-unini= tialized]
Quoted 18 lines
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 <[email protected]>--- drivers/net/wireless/ath/ath6kl/wmi.c | 8 ++++---- drivers/net/wireless/intel/ipw2x00/libipw_rx.c | 2 +- drivers/net/wireless/intersil/hostap/hostap_80211_rx.c | 2 +- net/wireless/lib80211_crypt_tkip.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-)
[...]
net/wireless/lib80211_crypt_tkip.c static void michael_mic_hdr(struct sk_buff *skb, u8 *=
Quoted 3 lines
net/wireless/lib80211_crypt_tkip.c +0
-0@@ -556,7 +556,7 @@ static void michael_mic_hdr(struct sk_buff *skb, u8 *=
hdr)
net/wireless/lib80211_crypt_tkip.c static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr) · line 562
Quoted 8 lines
net/wireless/lib80211_crypt_tkip.c +1
-1memcpy (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 ;
Ideally we prefer that drivers/net/wireless and net/wireless changes are split into different patches as they get applied to different trees. Johannes, is it ok if I take this change through my tree this time?
--=20
Kalle Valo
Johannes Berg
maintainerRe: [PATCH] wireless: fix bogus maybe-uninitialized warning
Quoted 5 lines
Ideally we prefer that
drivers/net/wirelessand net/wireless changes are
split into different patches as they get applied to different trees. Johannes, is it ok if I take this change through my tree this time?
Sure, please do, thanks.
(I don't particularly care about the lib80211 stuff anyway)
johannes
Re: [PATCH] wireless: fix bogus maybe-uninitialized warning
Quoted 4 lines · CET Johannes Berg
Quoted 4 lines
Ideally we prefer that
drivers/net/wirelessand net/wireless changes are
split into different patches as they get applied to different trees.
Ok, good to know. I had split out the drivers/staging changes, but wasn't sure about the granularity you'd want here.
Quoted 5 lines
Quoted 1 line
Johannes, is it ok if I take this change through my tree this time?
Sure, please do, thanks.
(I don't particularly care about the lib80211 stuff anyway)
Thanks!
Arnd
Re: wireless: fix bogus maybe-uninitialized warning
In reply to Arnd BergmannQuoted 15 lines · Arnd Bergmann
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.
Quoted 7 lines
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 <[email protected]>
Patch applied to wireless-drivers-next.git, thanks.
10f3366b4d89 wireless: fix bogus maybe-uninitialized warning
Signature · 6 lines
https://patchwork.kernel.org/patch/9392385/ Documentation about submitting wireless patches and checking status from patchwork: https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches