linux/drivers/staging/rtl8821ae
Surendra Patil fdf2f40c6c staging: rtl8821ae: Fixed the size of array to macro as discussed by Linus
Linus Torvalds writes:

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).

Reported-By: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Surendra Patil <surendra.tux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-07 09:15:35 -08:00
..
btcoexist
rtl8821ae staging: r8821ae: Fix build problems 2014-01-27 09:39:40 -08:00
base.c staging: r8821ae: Fix build problems 2014-01-27 09:39:40 -08:00
base.h
cam.c
cam.h
compat.h
core.c
core.h
debug.c
debug.h
efuse.c
efuse.h
Kconfig staging: r8821ae: Enable build by reverting BROKEN marking 2014-01-27 09:41:05 -08:00
Makefile
pci.c
pci.h
ps.c staging: r8821ae: Fix build problems 2014-01-27 09:39:40 -08:00
ps.h
rc.c
rc.h
regd.c
regd.h staging: r8821ae: Fix build problems 2014-01-27 09:39:40 -08:00
stats.c
stats.h
TODO Staging: rtl8821ae: add TODO file 2014-01-23 09:39:11 -08:00
wifi.h staging: rtl8821ae: Fixed the size of array to macro as discussed by Linus 2014-02-07 09:15:35 -08:00