Search Linux Wireless

Re: [PATCH 1/6] ath6kl: fix sparse warning on init.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 20, 2011 at 09:40:19PM +0200, Kalle Valo wrote:
> On 12/20/2011 08:46 PM, Luis R. Rodriguez wrote:
> > From: Luis R. Rodriguez <mcgrof@xxxxxxxxxxxxxxxx>
> > 
> > This fixes this sparse warning:
> > 
> >   CC [M]  drivers/net/wireless/ath/ath6kl/init.o
> > drivers/net/wireless/ath/ath6kl/init.c: In function ‘ath6kl_init_hw_params’:
> > drivers/net/wireless/ath/ath6kl/init.c:1377:26: warning: ‘hw’ may be used uninitialized in this function
> 
> That's a compiler warning.
> 
> >  static int ath6kl_init_hw_params(struct ath6kl *ar)
> >  {
> > -	const struct ath6kl_hw *hw;
> > +	const struct ath6kl_hw *hw = NULL;
> >  	int i;
> >  
> >  	for (i = 0; i < ARRAY_SIZE(hw_list); i++) {
> > @@ -1390,6 +1390,9 @@ static int ath6kl_init_hw_params(struct ath6kl *ar)
> >  		return -EINVAL;
> >  	}
> >  
> > +	if (!hw)
> > +		return -EINVAL;
> 
> I can't see how hw can be uninitialised here (looking at the version in
> ath6kl.git). I copy the full code here:
> 
> static int ath6kl_init_hw_params(struct ath6kl *ar)
> {
> 	const struct ath6kl_hw *hw;
> 	int i;
> 
> 	for (i = 0; i < ARRAY_SIZE(hw_list); i++) {
> 		hw = &hw_list[i];
> 
> 		if (hw->id == ar->version.target_ver)
> 			break;
> 	}
> 
> 	if (i == ARRAY_SIZE(hw_list)) {
> 		ath6kl_err("Unsupported hardware version: 0x%x\n",
> 			   ar->version.target_ver);
> 		return -EINVAL;
> 	}
> 
> 	ar->hw = *hw;
> 
> I always check for both compiler and sparse warnings and I have never
> seen this. What version of compiler do you have?
> 
> I have:
> 
> gcc-4.5.real (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2

Same.

mcgrof@tux ~ $ gcc --version
gcc-4.5.real (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

  Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux