rtlwifi: rtl8192cu: remove pointless memcpy
PATCH 1/1 rtlwifi: rtl8192cu: remove pointless memcpy
gcc-8 points out that source and destination of the memcpy() are always the same pointer, so the effect of memcpy() is undefined here (its arguments must not overlap):
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c: In function '_rtl_rx_process':drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:430:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]
Most likely this is harmless, but it's easy to just remove the line and get rid of the warning.
--- drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c +0 -1
@@ -427,7 +427,6 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) (u32 )hdr->addr1[0 ], (u32 )hdr->addr1[1 ], (u32 )hdr->addr1[2 ], (u32 )hdr->addr1[3 ], (u32)hdr->addr1[4], (u32)hdr->addr1[5]); -memcpy (IEEE80211_SKB_RXCB (skb), rx_status,sizeof (*rx_status));ieee80211_rx (hw, skb); }
Signature · 1 line
2.9.0
Quoted 20 lines · Arnd Bergmann
gcc-8 points out that source and destination of the
memcpy()are always the same pointer, so the effect ofmemcpy()is undefined here (its arguments must not overlap):
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c: In function '_rtl_rx_process':drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:430:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]Most likely this is harmless, but it's easy to just remove the line and get rid of the warning.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 1 - 1 file changed, 1 deletion(-)drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c +0
-0
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) · line 431
Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c +0
-1@@ -427,7 +427,6 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) (u32 )hdr->addr1[0 ], (u32 )hdr->addr1[1 ], (u32 )hdr->addr1[2 ], (u32 )hdr->addr1[3 ], (u32)hdr->addr1[4], (u32)hdr->addr1[5]); -memcpy (IEEE80211_SKB_RXCB (skb), rx_status,sizeof (*rx_status));ieee80211_rx (hw, skb); }
trivia:
The RT_TRACE above this should probably use %pM too. Not submitted as it would just cause a conflict.
---
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c +2 -5
@@ -422,11 +422,8 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)if (ieee80211_is_data (fc))RT_TRACE (rtlpriv,COMP_INIT ,DBG_DMESG ,"Got data frame\n" );RT_TRACE (rtlpriv,COMP_INIT ,DBG_DMESG , -"Fram: fc = 0x%X addr1 = 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X\n" , - fc, - (u32 )hdr->addr1[0 ], (u32 )hdr->addr1[1 ], - (u32 )hdr->addr1[2 ], (u32 )hdr->addr1[3 ], - (u32 )hdr->addr1[4 ], (u32 )hdr->addr1[5 ]); +"Fram: fc = 0x%X addr1 = %pM\n" , + fc, hdr->addr1);memcpy (IEEE80211_SKB_RXCB (skb), rx_status,sizeof (*rx_status));ieee80211_rx (hw, skb); }
Larry Finger
NAKQuoted 20 lines · Arnd Bergmann
gcc-8 points out that source and destination of the
memcpy()are always the same pointer, so the effect ofmemcpy()is undefined here (its arguments must not overlap):
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c: In function '_rtl_rx_process':drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:430:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]Most likely this is harmless, but it's easy to just remove the line and get rid of the warning.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 1 - 1 file changed, 1 deletion(-)drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c +0
-0
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) · line 431
Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c +0
-1@@ -427,7 +427,6 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) (u32 )hdr->addr1[0 ], (u32 )hdr->addr1[1 ], (u32 )hdr->addr1[2 ], (u32 )hdr->addr1[3 ], (u32)hdr->addr1[4], (u32)hdr->addr1[5]); -memcpy (IEEE80211_SKB_RXCB (skb), rx_status,sizeof (*rx_status));ieee80211_rx (hw, skb); }
No, the warning is pointing to the wrong place. The routine in question does the following:
1. Loads the rx_status struct from skb->cb.
2. Overwrites the contents with 0.
3. Fills various members of the struct.
4. Writes the revised struct back into skb->cb.
Thus eliminating step 4 negates all the things done in step 3, and is wrong. The correct fix is to change step 1 to create a NULL-filled rx_status struct, and eliminate step 2.
NACK.
Larry
Quoted 20 lines · Arnd Bergmann
gcc-8 points out that source and destination of the
memcpy()are always the same pointer, so the effect ofmemcpy()is undefined here (its arguments must not overlap):
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c: In function '_rtl_rx_process':drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:430:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]Most likely this is harmless, but it's easy to just remove the line and get rid of the warning.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 1 - 1 file changed, 1 deletion(-)drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c +0
-0
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) · line 431
Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c +0
-1@@ -427,7 +427,6 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) (u32 )hdr->addr1[0 ], (u32 )hdr->addr1[1 ], (u32 )hdr->addr1[2 ], (u32 )hdr->addr1[3 ], (u32)hdr->addr1[4], (u32)hdr->addr1[5]); -memcpy (IEEE80211_SKB_RXCB (skb), rx_status,sizeof (*rx_status));ieee80211_rx (hw, skb); }
Argh. Once again I got tripped up on pointers. Yes, this patch is correct.
Sorry about the noise.
Larry
Quoted 4 lines · Arnd Bergmann
gcc-8 points out that source and destination of the
memcpy()are always the same pointer, so the effect ofmemcpy()is undefined here (its arguments must not overlap):
Quoted 8 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c: In function '_rtl_rx_process':drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:430:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]Most likely this is harmless, but it's easy to just remove the line and get rid of the warning.
Signed-off-by Arnd Bergmann <[email protected]>Acked-by Larry Finger <[email protected]>
Patch applied to wireless-drivers-next.git, thanks.
dcdd54c2bcae rtlwifi: rtl8192cu: remove pointless memcpy
Signature · 3 lines
https://patchwork.kernel.org/patch/10208979/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches