linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix uninitialized-variable warnings.
@ 2013-04-11 18:02 Han Shen
  2013-04-11 18:35 ` Joe Perches
  2013-04-20  6:51 ` Rafał Miłecki
  0 siblings, 2 replies; 9+ messages in thread
From: Han Shen @ 2013-04-11 18:02 UTC (permalink / raw)
  To: linux-wireless; +Cc: Larry.Finger, chaoming_li, 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.

Signed-off-by: Han Shen  (shenhan@google.com)
---
 drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
index b793a65..875e36f 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
@@ -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);
-- 
1.8.1.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] Fix uninitialized-variable warnings.
  2013-04-11 18:02 [PATCH] Fix uninitialized-variable warnings Han Shen
@ 2013-04-11 18:35 ` Joe Perches
  2013-04-11 19:51   ` Larry Finger
  2013-04-11 20:00   ` Larry Finger
  2013-04-20  6:51 ` Rafał Miłecki
  1 sibling, 2 replies; 9+ messages in thread
From: Joe Perches @ 2013-04-11 18:35 UTC (permalink / raw)
  To: Han Shen; +Cc: linux-wireless, Larry.Finger, chaoming_li

On Thu, 2013-04-11 at 11:02 -0700, Han Shen wrote:
> 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(+)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
index b793a65..56b2b2f 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
@@ -717,6 +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,



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] Fix uninitialized-variable warnings.
  2013-04-11 18:35 ` Joe Perches
@ 2013-04-11 19:51   ` Larry Finger
  2013-04-11 20:00   ` Larry Finger
  1 sibling, 0 replies; 9+ messages in thread
From: Larry Finger @ 2013-04-11 19:51 UTC (permalink / raw)
  To: Joe Perches; +Cc: Han Shen, linux-wireless, chaoming_li

On 04/11/2013 01:35 PM, Joe Perches wrote:
> On Thu, 2013-04-11 at 11:02 -0700, Han Shen wrote:
>> 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(+)
>
> diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> index b793a65..56b2b2f 100644
> --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> @@ -717,6 +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,
>
>
> --

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:

Index: wireless-testing-save/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
===================================================================
--- wireless-testing-save.orig/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+++ wireless-testing-save/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
@@ -669,7 +669,7 @@ static void rtl92c_dm_txpower_tracking_c
         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], 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_c

                 for (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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Fix uninitialized-variable warnings.
  2013-04-11 18:35 ` Joe Perches
  2013-04-11 19:51   ` Larry Finger
@ 2013-04-11 20:00   ` Larry Finger
  2013-04-12 22:20     ` Han Shen(沈涵)
  1 sibling, 1 reply; 9+ messages in thread
From: Larry Finger @ 2013-04-11 20:00 UTC (permalink / raw)
  To: Joe Perches; +Cc: Han Shen, linux-wireless, chaoming_li

On 04/11/2013 01:35 PM, Joe Perches wrote:
> On Thu, 2013-04-11 at 11:02 -0700, Han Shen wrote:
>> 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(+)
>
> diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> index b793a65..56b2b2f 100644
> --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> @@ -717,6 +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,

My earlier E-mail was too hasty. Joe's patch is correct. It should be marked for 
stable (2.6.39+).

Larry




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Fix uninitialized-variable warnings.
  2013-04-11 20:00   ` Larry Finger
@ 2013-04-12 22:20     ` Han Shen(沈涵)
  2013-04-13  0:42       ` Larry Finger
  0 siblings, 1 reply; 9+ messages in thread
From: Han Shen(沈涵) @ 2013-04-12 22:20 UTC (permalink / raw)
  To: Larry Finger; +Cc: Joe Perches, linux-wireless, chaoming_li

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,

On Thu, Apr 11, 2013 at 1:00 PM, Larry Finger <Larry.Finger@lwfinger.net> wrote:
> On 04/11/2013 01:35 PM, Joe Perches wrote:
>>
>> On Thu, 2013-04-11 at 11:02 -0700, Han Shen wrote:
>>>
>>> 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(+)
>>
>> diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
>> b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
>> index b793a65..56b2b2f 100644
>> --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
>> +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
>> @@ -717,6 +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,
>
>
> My earlier E-mail was too hasty. Joe's patch is correct. It should be marked
> for stable (2.6.39+).
>
> Larry
>
>
>



-- 
Han Shen |  Software Engineer |  shenhan@google.com |  +1-650-440-3330

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Fix uninitialized-variable warnings.
  2013-04-12 22:20     ` Han Shen(沈涵)
@ 2013-04-13  0:42       ` Larry Finger
  2013-04-19 20:43         ` Han Shen(沈涵)
  0 siblings, 1 reply; 9+ messages in thread
From: Larry Finger @ 2013-04-13  0:42 UTC (permalink / raw)
  To: "Han Shen(沈涵)"
  Cc: Joe Perches, linux-wireless, chaoming_li

On 04/12/2013 05:20 PM, Han Shen(沈涵) wrote:
> 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.)

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Fix uninitialized-variable warnings.
  2013-04-13  0:42       ` Larry Finger
@ 2013-04-19 20:43         ` Han Shen(沈涵)
  2013-04-19 23:28           ` Joe Perches
  0 siblings, 1 reply; 9+ messages in thread
From: Han Shen(沈涵) @ 2013-04-19 20:43 UTC (permalink / raw)
  To: Larry Finger; +Cc: Joe Perches, linux-wireless, chaoming_li

Hi Larry, thanks. I've prepared below (simple) patch just adding
initialization list and what Joe's patch does.

Is this ok?

H.

Signed-off-by: Han Shen  (shenhan@google.com)
---
 drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
index b793a65..34150de 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
@@ -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

On Fri, Apr 12, 2013 at 5:42 PM, Larry Finger <Larry.Finger@lwfinger.net> wrote:
> On 04/12/2013 05:20 PM, Han Shen(沈涵) wrote:
>>
>> 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.)
>
>
> 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
>
>



-- 
Han Shen |  Software Engineer |  shenhan@google.com |  +1-650-440-3330

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] Fix uninitialized-variable warnings.
  2013-04-19 20:43         ` Han Shen(沈涵)
@ 2013-04-19 23:28           ` Joe Perches
  0 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2013-04-19 23:28 UTC (permalink / raw)
  To: Han Shen(沈涵); +Cc: Larry Finger, linux-wireless, chaoming_li

On Fri, 2013-04-19 at 13:43 -0700, Han Shen(沈涵) wrote:
> 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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Fix uninitialized-variable warnings.
  2013-04-11 18:02 [PATCH] Fix uninitialized-variable warnings Han Shen
  2013-04-11 18:35 ` Joe Perches
@ 2013-04-20  6:51 ` Rafał Miłecki
  1 sibling, 0 replies; 9+ messages in thread
From: Rafał Miłecki @ 2013-04-20  6:51 UTC (permalink / raw)
  To: Han Shen; +Cc: linux-wireless, Larry.Finger, chaoming_li

2013/4/11 Han Shen <shenhan@google.com>:
> 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

-- 
Rafał

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-04-20  6:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-11 18:02 [PATCH] Fix uninitialized-variable warnings Han Shen
2013-04-11 18:35 ` Joe Perches
2013-04-11 19:51   ` Larry Finger
2013-04-11 20:00   ` Larry Finger
2013-04-12 22:20     ` Han Shen(沈涵)
2013-04-13  0:42       ` Larry Finger
2013-04-19 20:43         ` Han Shen(沈涵)
2013-04-19 23:28           ` Joe Perches
2013-04-20  6:51 ` Rafał Miłecki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).