Re: [PATCH] drivers:staging:tl8821ae Fixed the size of array to macro

2014-02-03 Thread Dan Carpenter
On Sat, Feb 01, 2014 at 03:43:27PM -0800, Surendra Patil wrote:
 Changed array size from bb_swing_idx_ofdm[2] to 
 bb_swing_idx_ofdm[MAX_RF_PATH]
 as discussed on thread - https://lkml.org/lkml/2014/2/1/75
 

Changelog sucks.  We don't want to have to follow the link.  Add a
Reported-by: Linus Torvalds torva...@linux-foundation.org

regards,
dan carpenter

 Signed-off-by: Surendra Patil surendra@gmail.com
 ---
  drivers/staging/rtl8821ae/wifi.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/staging/rtl8821ae/wifi.h 
 b/drivers/staging/rtl8821ae/wifi.h
 index cfe88a1..76bef93 100644
 --- a/drivers/staging/rtl8821ae/wifi.h
 +++ b/drivers/staging/rtl8821ae/wifi.h
 @@ -1414,7 +1414,7 @@ struct rtl_dm {
  
  
   /*88e tx power tracking*/
 - u8 bb_swing_idx_ofdm[2];
 + u8 bb_swing_idx_ofdm[MAX_RF_PATH];
   u8 bb_swing_idx_ofdm_current;
   u8 bb_swing_idx_ofdm_base[MAX_RF_PATH];
   bool bb_swing_flag_Ofdm;
 -- 
 1.8.3.2
 
 ___
 devel mailing list
 de...@linuxdriverproject.org
 http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] drivers:staging:tl8821ae Fixed the size of array to macro as discussed by Linus

2014-02-03 Thread Surendra Patil
Reported-By: Linus Torvalds torva...@linux-foundation.org
It causes an interesting warning for me:

drivers/staging/rtl8821ae/rtl8821ae/dm.c: In function
???rtl8821ae_dm_clear_txpower_tracking_state???:
drivers/staging/rtl8821ae/rtl8821ae/dm.c:487:31: warning: iteration 2u
invokes undefined behavior [-Waggressive-loop-optimizations]
   rtldm-bb_swing_idx_ofdm[p] = rtldm-default_ofdm_index;
   ^
drivers/staging/rtl8821ae/rtl8821ae/dm.c:485:2: note: containing loop
  for (p = RF90_PATH_A; p  MAX_RF_PATH; ++p) {
  ^

and gcc is entirely correct: that loop iterates from 0 to 3, and does this:

rtldm-bb_swing_idx_ofdm[p] = rtldm-default_ofdm_index;

but the bb_swing_idx_ofdm[] array only has two members. So the last
two iterations will overwrite bb_swing_idx_ofdm_current and the first
entry in bb_swing_idx_ofdm_base[].

Now, the bug does seem to be benign: bb_swing_idx_ofdm_current isn't
actually ever *used* as far as I can tell, and the first entry of
bb_swing_idx_ofdm_base[] will have been written with that same
rtldm-default_ofdm_index value.

But gcc is absolutely correct, and that driver needs fixing.

I've pulled it and will let it be because it doesn't seem to be an
issue in practice, but please fix it. The obvious fix would seem to
change the size of 2 to be MAX_RF_PATH, but I'll abstain from
doing those kinds of changes in the merge when it doesn't seem to
affect the build or functionality).

Signed-off-by: Surendra Patil surendra@gmail.com
---
 drivers/staging/rtl8821ae/wifi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8821ae/wifi.h b/drivers/staging/rtl8821ae/wifi.h
index cfe88a1..76bef93 100644
--- a/drivers/staging/rtl8821ae/wifi.h
+++ b/drivers/staging/rtl8821ae/wifi.h
@@ -1414,7 +1414,7 @@ struct rtl_dm {
 
 
/*88e tx power tracking*/
-   u8 bb_swing_idx_ofdm[2];
+   u8 bb_swing_idx_ofdm[MAX_RF_PATH];
u8 bb_swing_idx_ofdm_current;
u8 bb_swing_idx_ofdm_base[MAX_RF_PATH];
bool bb_swing_flag_Ofdm;
-- 
1.8.3.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel