Fix uninitialized-variable warnings.
PATCH 1/1 Fix uninitialized-variable warnings.
GCC 4.8 is spitting out uninitialized-varaible warnings against "drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c". This trivial patch just adds initialization to the variable.
--- drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +1 -1
@@ -669,7 +669,7 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hwu8 thermalvalue, delta, delta_lck, delta_iqk;long ele_a, ele_d, temp_cck, val_x, value32;long val_y, ele_c =0 ; -u8 ofdm_index[2 ], ofdm_index_old[2 ], cck_index_old =0 ; +u8 ofdm_index[2 ], ofdm_index_old[2 ] = {0 ,0 }, cck_index_old =0 ;s8 cck_index =0 ;int i;bool is2t =IS_92C_SERIAL (rtlhal->version);
Signature · 1 line
1.8.1.3
Quoted 2 lines · Han Shen
GCC 4.8 is spitting out uninitialized-varaible warnings against "
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c". This trivial patch just adds initialization to the variable.
Not sure this is correct.
I think the logic should be inspected instead.
ofdm_index_old[1] _is_ used uninitialized.
It appears there might be a missing
ofdm_index_old[1] = (u8) i;
as that's the same style test done in the
section above.
Maybe this:
--- drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +1 -0
@@ -717,6 +717,7 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hwfor (i =0 ; i <OFDM_TABLE_LENGTH ; i++) {if (ele_d == (ofdmswing_table[i] &MASKOFDM_D )) { + ofdm_index_old[1 ] = (u8 ) i; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
Quoted 26 lines · Joe Perches
Quoted 2 lines · Han Shen
GCC 4.8 is spitting out uninitialized-varaible warnings against "
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c". This trivial patch just adds initialization to the variable.Not sure this is correct.
I think the logic should be inspected instead.ofdm_index_old[1] _is_ used uninitialized.
It appears there might be a missing
ofdm_index_old[1] = (u8) i;as that's the same style test done in the
section above.Maybe this:
--- drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 1 + 1 file changed, 1 insertion(+)drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +0
-0
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
Quoted 10 lines
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +1
-1@@ -717,6 +717,7 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hwfor (i =0 ; i <OFDM_TABLE_LENGTH ; i++) {if (ele_d == (ofdmswing_table[i] &MASKOFDM_D )) { + ofdm_index_old[1 ] = (u8 ) i; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, --
Joe's patch would work, but as the elements of ofdm_index_old[] are just filled with the contents of i, just eliominate the middle man as in:
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +1 -3
@@ -669,7 +669,7 @@ static void rtl92c_dm_txpower_tracking_cu8 thermalvalue, delta, delta_lck, delta_iqk;long ele_a, ele_d, temp_cck, val_x, value32;long val_y, ele_c =0 ; -u8 ofdm_index[2 ], ofdm_index_old[2 ], cck_index_old =0 ; +u8 ofdm_index[2 ], cck_index_old =0 ;s8 cck_index =0 ;int i;bool is2t =IS_92C_SERIAL (rtlhal->version);
@@ -700,12 +700,10 @@ static void rtl92c_dm_txpower_tracking_cfor (i =0 ; i <OFDM_TABLE_LENGTH ; i++) {if (ele_d == (ofdmswing_table[i] &MASKOFDM_D )) { - ofdm_index_old[0 ] = (u8 ) i; - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "Initial pathA ele_d reg0x%x = 0x%lx,
ofdm_index=0x%x\n",
ROFDM0_XATXIQIMBALANCE,
- ele_d, ofdm_index_old[0]);
+ ele_d, i);
break;
}
}
@@ -722,7 +720,7 @@ static void rtl92c_dm_txpower_tracking_c
DBG_LOUD,
"Initial pathB ele_d reg0x%x =
0x%lx, ofdm_index=0x%x\n",
ROFDM0_XBTXIQIMBALANCE, ele_d,
- ofdm_index_old[1]);
+ i);
break;
}
}I will submit this as a proper patch later. Fortunately, the driver is seldom run with the debug level as high as DBG_LOUD, then the RT_TRACE statements rarely result in any output.
Larry
Larry
Quoted 26 lines · Joe Perches
Quoted 2 lines · Han Shen
GCC 4.8 is spitting out uninitialized-varaible warnings against "
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c". This trivial patch just adds initialization to the variable.Not sure this is correct.
I think the logic should be inspected instead.ofdm_index_old[1] _is_ used uninitialized.
It appears there might be a missing
ofdm_index_old[1] = (u8) i;as that's the same style test done in the
section above.Maybe this:
--- drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 1 + 1 file changed, 1 insertion(+)drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +0
-0
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw · line 723
Quoted 7 lines
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +1
-0@@ -717,6 +717,7 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hwfor (i =0 ; i <OFDM_TABLE_LENGTH ; i++) {if (ele_d == (ofdmswing_table[i] &MASKOFDM_D )) { + ofdm_index_old[1 ] = (u8 ) i; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
My earlier E-mail was too hasty. Joe's patch is correct. It should be marked for stable (2.6.39+).
Larry
Hi, Joe's patch (the 1-line fix) does not work for me. The assignment is in a conditional block, when refer to this ofdm_index_old later, I still get error -
/mnt/host/source/src/third_party/kernel/files/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c:771:31:
error: 'ofdm_index_old[1]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
rtlpriv->dm.ofdm_index[i] = ofdm_index_old[i];
(I'm working on 3.4 branch.)
Thanks,
Quoted 50 lines · Larry Finger
Quoted 32 lines · Joe Perches
Quoted 4 lines · Han Shen
GCC 4.8 is spitting out uninitialized-varaible warnings against "
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c". This trivial patch just adds initialization to the variable.Not sure this is correct.
I think the logic should be inspected instead.ofdm_index_old[1] _is_ used uninitialized.
It appears there might be a missing
ofdm_index_old[1] = (u8) i;as that's the same style test done in the
section above.Maybe this:
--- drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 1 + 1 file changed, 1 insertion(+)drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +0
-0@@ -717,6 +717,7 @@ static voidrtl92c_dm_txpower_tracking_callback_thermalmeter(struct
ieee80211_hwQuoted 8 lines
for (i = 0; i < OFDM_TABLE_LENGTH; i++) { if (ele_d == (ofdmswing_table[i] & MASKOFDM_D)) {+ ofdm_index_old[1] = (u8) i;
RT_TRACE(rtlpriv,
COMP_POWER_TRACKING,
DBG_LOUD,My earlier E-mail was too hasty. Joe's patch is correct. It should be marked for stable (2.6.39+).
Larry
Signature · 1 line
Han Shen | Software Engineer | [email protected] | +1-650-440-3330
Quoted 10 lines · Han Shen(沈涵)
Hi, Joe's patch (the 1-line fix) does not work for me. The assignment is in a conditional block, when refer to this
ofdm_index_oldlater, I still get error -
/mnt/host/source/src/third_party/kernel/files/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c:771:31:
error: 'ofdm_index_old[1]' may be used uninitialized in this function [-Werror=maybe-uninitialized]rtlpriv->dm.ofdm_index[i] = ofdm_index_old[i];(I'm working on 3.4 branch.)
I would get rid of the -Werror=maybe-unitialized. Sometimes gcc generates a false warning, and you really should not error the build in that case.
The correct patch needs to initialize the array to 0, and set the element the way Joe's patch does.
Larry
Hi Larry, thanks. I've prepared below (simple) patch just adding initialization list and what Joe's patch does.
Is this ok?
H.
--- drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0
b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c index b793a65..34150de 100644
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +0 -0
@@ -669,7 +669,7 @@ static void
rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
u8 thermalvalue, delta, delta_lck, delta_iqk;
long ele_a, ele_d, temp_cck, val_x, value32;
long val_y, ele_c = 0;
- u8 ofdm_index[2], ofdm_index_old[2], cck_index_old = 0;
+ u8 ofdm_index[2], ofdm_index_old[2] = {0, 0}, cck_index_old = 0; s8 cck_index = 0;
int i;
bool is2t = IS_92C_SERIAL(rtlhal->version);
@@ -717,7 +717,7 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
for (i = 0; i < OFDM_TABLE_LENGTH; i++) {
if (ele_d == (ofdmswing_table[i] &
MASKOFDM_D)) {-
+ ofdm_index_old[1] = (u8) i;
RT_TRACE(rtlpriv, COMP_POWER_TRACKING,
DBG_LOUD,
"Initial pathB ele_d reg0x%x = 0x%lx, ofdm_index=0x%x\n",
--
1.8.2.1
Quoted 24 lines · Larry Finger
Quoted 6 lines · Han Shen(沈涵)
Hi, Joe's patch (the 1-line fix) does not work for me. The assignment is in a conditional block, when refer to this
ofdm_index_oldlater, I still get error -Quoted 6 lines
/mnt/host/source/src/third_party/kernel/files/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c:771:31:
error: 'ofdm_index_old[1]' may be used uninitialized in this function [-Werror=maybe-uninitialized]rtlpriv->dm.ofdm_index[i] = ofdm_index_old[i];(I'm working on 3.4 branch.)
I would get rid of the -Werror=maybe-unitialized. Sometimes gcc generates a false warning, and you really should not error the build in that case.
The correct patch needs to initialize the array to 0, and set the element the way Joe's patch does.
Larry
Signature · 1 line
Han Shen | Software Engineer | [email protected] | +1-650-440-3330
Quoted 4 lines · Han Shen(沈涵)
I've prepared below (simple) patch just adding
initialization list and what Joe's patch does.Is this ok?
No. It's whitespace damaged.
Try to make sure your patch applies by first sending it to yourself and then check to see if git am accepts it without warnings or errors.
2013/4/11 Han Shen <[email protected]>:
Quoted 2 lines
GCC 4.8 is spitting out uninitialized-varaible warnings against "
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c". This trivial patch just adds initialization to the variable.
Could you use prefixes for your patches? Like
rtl8192c: foo
Signature · 1 line
Rafał