linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]: ath: Fix uninitialized variable warnings
@ 2010-05-27 18:15 Prarit Bhargava
  0 siblings, 0 replies; 5+ messages in thread
From: Prarit Bhargava @ 2010-05-27 18:15 UTC (permalink / raw)
  To: linux-wireless, linville; +Cc: Prarit Bhargava

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2447 bytes --]

Fixes 'make -j24 CONFIG_DEBUG_SECTION_MISMATCH=y' warning:

drivers/net/wireless/ath/ath9k/eeprom_4k.c: In function ‘ath9k_hw_get_4k_gain_boundaries_pdadcs.clone.1’:
drivers/net/wireless/ath/ath9k/eeprom_4k.c:311: error: ‘minPwrT4’ may be used uninitialized in this function
drivers/net/wireless/ath/ath9k/eeprom_9287.c: In function ‘ath9k_hw_get_AR9287_gain_boundaries_pdadcs’:
drivers/net/wireless/ath/ath9k/eeprom_9287.c:302: error: ‘minPwrT4’ may be used uninitialized in this function
drivers/net/wireless/ath/ath9k/eeprom_def.c: In function ‘ath9k_hw_get_def_gain_boundaries_pdadcs.clone.0’:
drivers/net/wireless/ath/ath9k/eeprom_def.c:679: error: ‘minPwrT4’ may be used uninitialized in this function

Signed-off-by: Prarit Bhargava <prarit@redhat.com>

diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
index 41a77d1..e25a2ab 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
@@ -249,6 +249,7 @@ static void ath9k_hw_get_4k_gain_boundaries_pdadcs(struct ath_hw *ah,
 	struct chan_centers centers;
 #define PD_GAIN_BOUNDARY_DEFAULT 58;
 
+	memset(&minPwrT4, 0, AR9287_NUM_PD_GAINS);
 	ath9k_hw_get_channel_centers(ah, chan, &centers);
 
 	for (numPiers = 0; numPiers < availPiers; numPiers++) {
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
index b471db5..9b0478d 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
@@ -245,6 +245,7 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah,
 	static u8 vpdTableI[AR5416_EEP4K_NUM_PD_GAINS]
 		[AR5416_MAX_PWR_RANGE_IN_HALF_DB];
 
+	memset(&minPwrT4, 0, AR9287_NUM_PD_GAINS);
 	ath9k_hw_get_channel_centers(ah, chan, &centers);
 
 	for (numPiers = 0; numPiers < availPiers; numPiers++) {
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c
index e591ad6..9019b6e 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
@@ -618,6 +618,7 @@ static void ath9k_hw_get_def_gain_boundaries_pdadcs(struct ath_hw *ah,
 	int16_t minDelta = 0;
 	struct chan_centers centers;
 
+	memset(&minPwrT4, 0, AR9287_NUM_PD_GAINS);
 	ath9k_hw_get_channel_centers(ah, chan, &centers);
 
 	for (numPiers = 0; numPiers < availPiers; numPiers++) {

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

* Re: [PATCH]: ath: Fix uninitialized variable warnings
       [not found] <20100527181052.23905.67123.sendpatchset@prarit.bos.redhat.com>
@ 2010-05-28 17:34 ` John W. Linville
  2010-05-28 20:44   ` Pavel Roskin
  0 siblings, 1 reply; 5+ messages in thread
From: John W. Linville @ 2010-05-28 17:34 UTC (permalink / raw)
  To: Prarit Bhargava; +Cc: linux-wireless, ath9k-devel

On Thu, May 27, 2010 at 02:14:54PM -0400, Prarit Bhargava wrote:
> Fixes 'make -j24 CONFIG_DEBUG_SECTION_MISMATCH=y' warning:
> 
> drivers/net/wireless/ath/ath9k/eeprom_4k.c: In function ‘ath9k_hw_get_4k_gain_boundaries_pdadcs.clone.1’:
> drivers/net/wireless/ath/ath9k/eeprom_4k.c:311: error: ‘minPwrT4’ may be used uninitialized in this function
> drivers/net/wireless/ath/ath9k/eeprom_9287.c: In function ‘ath9k_hw_get_AR9287_gain_boundaries_pdadcs’:
> drivers/net/wireless/ath/ath9k/eeprom_9287.c:302: error: ‘minPwrT4’ may be used uninitialized in this function
> drivers/net/wireless/ath/ath9k/eeprom_def.c: In function ‘ath9k_hw_get_def_gain_boundaries_pdadcs.clone.0’:
> drivers/net/wireless/ath/ath9k/eeprom_def.c:679: error: ‘minPwrT4’ may be used uninitialized in this function
> 
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>

It looks to me like minPwrT4 will get initialized as long as
numXpdGains is non-zero in all cases.  Anyone know if this is true?

It's probably not a big deal, but better to avoid an unnecessary
memset if we can.  Maybe unitialized_var is the better choice?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

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

* Re: [PATCH]: ath: Fix uninitialized variable warnings
  2010-05-28 17:34 ` [PATCH]: ath: Fix uninitialized variable warnings John W. Linville
@ 2010-05-28 20:44   ` Pavel Roskin
  2010-06-17 22:41     ` Prarit Bhargava
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Roskin @ 2010-05-28 20:44 UTC (permalink / raw)
  To: John W. Linville; +Cc: Prarit Bhargava, linux-wireless, ath9k-devel

On Fri, 2010-05-28 at 13:34 -0400, John W. Linville wrote:
> On Thu, May 27, 2010 at 02:14:54PM -0400, Prarit Bhargava wrote:
> > Fixes 'make -j24 CONFIG_DEBUG_SECTION_MISMATCH=y' warning:
> > 
> > drivers/net/wireless/ath/ath9k/eeprom_4k.c: In function ‘ath9k_hw_get_4k_gain_boundaries_pdadcs.clone.1’:
> > drivers/net/wireless/ath/ath9k/eeprom_4k.c:311: error: ‘minPwrT4’ may be used uninitialized in this function
> > drivers/net/wireless/ath/ath9k/eeprom_9287.c: In function ‘ath9k_hw_get_AR9287_gain_boundaries_pdadcs’:
> > drivers/net/wireless/ath/ath9k/eeprom_9287.c:302: error: ‘minPwrT4’ may be used uninitialized in this function
> > drivers/net/wireless/ath/ath9k/eeprom_def.c: In function ‘ath9k_hw_get_def_gain_boundaries_pdadcs.clone.0’:
> > drivers/net/wireless/ath/ath9k/eeprom_def.c:679: error: ‘minPwrT4’ may be used uninitialized in this function
> > 
> > Signed-off-by: Prarit Bhargava <prarit@redhat.com>
> 
> It looks to me like minPwrT4 will get initialized as long as
> numXpdGains is non-zero in all cases.  Anyone know if this is true?

It's calculated based on a value from EEPROM (xpdMask).  If xpdMask is
0, numXpdGain would be 0.  So bogus EEPROM can lead to bogus
tMinCalPower.  But the good thing is that tMinCalPower is never used.

So let's just eliminate tMinCalPower in all three files, as well as the
corresponding function arguments.

-- 
Regards,
Pavel Roskin

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

* Re: [PATCH]: ath: Fix uninitialized variable warnings
  2010-05-28 20:44   ` Pavel Roskin
@ 2010-06-17 22:41     ` Prarit Bhargava
  2010-06-19 17:33       ` Pavel Roskin
  0 siblings, 1 reply; 5+ messages in thread
From: Prarit Bhargava @ 2010-06-17 22:41 UTC (permalink / raw)
  To: linux-wireless; +Cc: Pavel Roskin, John W. Linville, ath9k-devel


>> It looks to me like minPwrT4 will get initialized as long as
>> numXpdGains is non-zero in all cases.  Anyone know if this is true?
> 
> It's calculated based on a value from EEPROM (xpdMask).  If xpdMask is
> 0, numXpdGain would be 0.  So bogus EEPROM can lead to bogus
> tMinCalPower.  But the good thing is that tMinCalPower is never used.
> 
> So let's just eliminate tMinCalPower in all three files, as well as the
> corresponding function arguments.
> 

[John -- I tried using wireless-next-2.6, however, the compile died with

drivers/net/wireless/wl12xx/wl1251_sdio.c: In function ‘wl1251_sdio_read_elp’:
drivers/net/wireless/wl12xx/wl1251_sdio.c:109: error: implicit declaration of function ‘sdio_writeb_readb’
make[4]: *** [drivers/net/wireless/wl12xx/wl1251_sdio.o] Error 1

I'll take a look and probably submit a patch to fix that right after I do this.]

Thanks for the input and help Pavel.  Sorry this is such a late response -- I
got caught up with a few other things.

New linux-2.6 patch using Pavel's suggestion.


Fix "make -j32 CONFIG_DEBUG_SECTION_MISMATCH=y" warning:

drivers/net/wireless/ath/ath9k/eeprom_9287.c: In function ‘ath9k_hw_get_AR9287_gain_boundaries_pdadcs’:
drivers/net/wireless/ath/ath9k/eeprom_9287.c:301: warning: ‘minPwrT4’ may be used uninitialized in this function
drivers/net/wireless/ath/ath9k/eeprom_4k.c: In function ‘ath9k_hw_get_4k_gain_boundaries_pdadcs.clone.1’:
drivers/net/wireless/ath/ath9k/eeprom_4k.c:310: warning: ‘minPwrT4’ may be used uninitialized in this function
drivers/net/wireless/ath/ath9k/eeprom_def.c: In function ‘ath9k_hw_get_def_gain_boundaries_pdadcs.clone.0’:
drivers/net/wireless/ath/ath9k/eeprom_def.c:677: warning: ‘minPwrT4’ may be used uninitialized in this function

Remove tMinCalPower and the corresponding function arguments  as it is not
used.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>

diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
index 41a77d1..393f8c5 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
@@ -222,7 +222,7 @@ static void ath9k_hw_get_4k_gain_boundaries_pdadcs(struct ath_hw *ah,
 				struct ath9k_channel *chan,
 				struct cal_data_per_freq_4k *pRawDataSet,
 				u8 *bChans, u16 availPiers,
-				u16 tPdGainOverlap, int16_t *pMinCalPower,
+				u16 tPdGainOverlap,
 				u16 *pPdGainBoundaries, u8 *pPDADCValues,
 				u16 numXpdGains)
 {
@@ -307,8 +307,6 @@ static void ath9k_hw_get_4k_gain_boundaries_pdadcs(struct ath_hw *ah,
 		}
 	}
 
-	*pMinCalPower = (int16_t)(minPwrT4[0] / 2);
-
 	k = 0;
 
 	for (i = 0; i < numXpdGains; i++) {
@@ -398,7 +396,6 @@ static void ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
 	static u8 pdadcValues[AR5416_NUM_PDADC_VALUES];
 	u16 gainBoundaries[AR5416_EEP4K_PD_GAINS_IN_MASK];
 	u16 numPiers, i, j;
-	int16_t tMinCalPower;
 	u16 numXpdGain, xpdMask;
 	u16 xpdGainValues[AR5416_EEP4K_NUM_PD_GAINS] = { 0, 0 };
 	u32 reg32, regOffset, regChainOffset;
@@ -451,7 +448,7 @@ static void ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
 			ath9k_hw_get_4k_gain_boundaries_pdadcs(ah, chan,
 					    pRawDataset, pCalBChans,
 					    numPiers, pdGainOverlap_t2,
-					    &tMinCalPower, gainBoundaries,
+					    gainBoundaries,
 					    pdadcValues, numXpdGain);
 
 			ENABLE_REGWRITE_BUFFER(ah);
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
index b471db5..6d6b1c5 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
@@ -219,7 +219,7 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah,
 				   struct ath9k_channel *chan,
 				   struct cal_data_per_freq_ar9287 *pRawDataSet,
 				   u8 *bChans,  u16 availPiers,
-				   u16 tPdGainOverlap, int16_t *pMinCalPower,
+				   u16 tPdGainOverlap,
 				   u16 *pPdGainBoundaries, u8 *pPDADCValues,
 				   u16 numXpdGains)
 {
@@ -298,7 +298,6 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah,
 			}
 		}
 	}
-	*pMinCalPower = (int16_t)(minPwrT4[0] / 2);
 
 	k = 0;
 	for (i = 0; i < numXpdGains; i++) {
@@ -448,7 +447,6 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah,
 	u8  pdadcValues[AR9287_NUM_PDADC_VALUES];
 	u16 gainBoundaries[AR9287_PD_GAINS_IN_MASK];
 	u16 numPiers = 0, i, j;
-	int16_t  tMinCalPower;
 	u16 numXpdGain, xpdMask;
 	u16 xpdGainValues[AR9287_NUM_PD_GAINS] = {0, 0, 0, 0};
 	u32 reg32, regOffset, regChainOffset;
@@ -514,7 +512,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah,
 						  ah, chan, pRawDataset,
 						  pCalBChans, numPiers,
 						  pdGainOverlap_t2,
-						  &tMinCalPower, gainBoundaries,
+						  gainBoundaries,
 						  pdadcValues, numXpdGain);
 			}
 
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c
index 7e1ed78..6ff2742 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
@@ -593,7 +593,7 @@ static void ath9k_hw_get_def_gain_boundaries_pdadcs(struct ath_hw *ah,
 				struct ath9k_channel *chan,
 				struct cal_data_per_freq *pRawDataSet,
 				u8 *bChans, u16 availPiers,
-				u16 tPdGainOverlap, int16_t *pMinCalPower,
+				u16 tPdGainOverlap,
 				u16 *pPdGainBoundaries, u8 *pPDADCValues,
 				u16 numXpdGains)
 {
@@ -674,8 +674,6 @@ static void ath9k_hw_get_def_gain_boundaries_pdadcs(struct ath_hw *ah,
 		}
 	}
 
-	*pMinCalPower = (int16_t)(minPwrT4[0] / 2);
-
 	k = 0;
 
 	for (i = 0; i < numXpdGains; i++) {
@@ -837,7 +835,7 @@ static void ath9k_hw_set_def_power_cal_table(struct ath_hw *ah,
 	static u8 pdadcValues[AR5416_NUM_PDADC_VALUES];
 	u16 gainBoundaries[AR5416_PD_GAINS_IN_MASK];
 	u16 numPiers, i, j;
-	int16_t tMinCalPower, diff = 0;
+	int16_t diff = 0;
 	u16 numXpdGain, xpdMask;
 	u16 xpdGainValues[AR5416_NUM_PD_GAINS] = { 0, 0, 0, 0 };
 	u32 reg32, regOffset, regChainOffset;
@@ -922,7 +920,6 @@ static void ath9k_hw_set_def_power_cal_table(struct ath_hw *ah,
 							chan, pRawDataset,
 							pCalBChans, numPiers,
 							pdGainOverlap_t2,
-							&tMinCalPower,
 							gainBoundaries,
 							pdadcValues,
 							numXpdGain);

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

* Re: [PATCH]: ath: Fix uninitialized variable warnings
  2010-06-17 22:41     ` Prarit Bhargava
@ 2010-06-19 17:33       ` Pavel Roskin
  0 siblings, 0 replies; 5+ messages in thread
From: Pavel Roskin @ 2010-06-19 17:33 UTC (permalink / raw)
  To: Prarit Bhargava; +Cc: linux-wireless, John W. Linville, ath9k-devel

On Thu, 2010-06-17 at 18:41 -0400, Prarit Bhargava wrote:
...
> New linux-2.6 patch using Pavel's suggestion.
> 
> 
> Fix "make -j32 CONFIG_DEBUG_SECTION_MISMATCH=y" warning:
> 
> drivers/net/wireless/ath/ath9k/eeprom_9287.c: In function ‘ath9k_hw_get_AR9287_gain_boundaries_pdadcs’:
> drivers/net/wireless/ath/ath9k/eeprom_9287.c:301: warning: ‘minPwrT4’ may be used uninitialized in this function
> drivers/net/wireless/ath/ath9k/eeprom_4k.c: In function ‘ath9k_hw_get_4k_gain_boundaries_pdadcs.clone.1’:
> drivers/net/wireless/ath/ath9k/eeprom_4k.c:310: warning: ‘minPwrT4’ may be used uninitialized in this function
> drivers/net/wireless/ath/ath9k/eeprom_def.c: In function ‘ath9k_hw_get_def_gain_boundaries_pdadcs.clone.0’:
> drivers/net/wireless/ath/ath9k/eeprom_def.c:677: warning: ‘minPwrT4’ may be used uninitialized in this function
> 
> Remove tMinCalPower and the corresponding function arguments  as it is not
> used.
> 
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>

Acked-by: Pavel Roskin <proski@gnu.org>

-- 
Regards,
Pavel Roskin

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

end of thread, other threads:[~2010-06-19 17:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20100527181052.23905.67123.sendpatchset@prarit.bos.redhat.com>
2010-05-28 17:34 ` [PATCH]: ath: Fix uninitialized variable warnings John W. Linville
2010-05-28 20:44   ` Pavel Roskin
2010-06-17 22:41     ` Prarit Bhargava
2010-06-19 17:33       ` Pavel Roskin
2010-05-27 18:15 Prarit Bhargava

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