Search Linux Wireless

Re: [PATCH] b43: Eliminate compilation warning in b43_op_set_key

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

 



On Wednesday 14 January 2009 16:47:09 Larry Finger wrote:
> John W. Linville wrote:
> > On Tue, Jan 13, 2009 at 06:20:25PM -0600, Larry Finger wrote:
> >> A recent pull from wireless testing generates the following warning:
> >>  
> >>    CC [M]  drivers/net/wireless/b43/main.o
> >>  drivers/net/wireless/b43/main.c: In function ‘b43_op_set_key’:
> >>  drivers/net/wireless/b43/main.c:3636: warning: pointer type mismatch
> >>  in conditional expression
> >>
> >> This fix was suggested by Johannes Berg <johannes@xxxxxxxxxxxxxxxx>.
> >>
> >> Signed-off-by: Larry Finger <Larry.Finger@xxxxxxxxxxxx>
> >> ---
> >>
> >> Index: wireless-testing/drivers/net/wireless/b43/main.c
> >> ===================================================================
> >> --- wireless-testing.orig/drivers/net/wireless/b43/main.c
> >> +++ wireless-testing/drivers/net/wireless/b43/main.c
> >> @@ -3630,10 +3630,12 @@ static int b43_op_set_key(struct ieee802
> >>  
> >>  out_unlock:
> >>  	if (!err) {
> >> +		u8 bcast[ETH_ALEN];
> >> +		memset(bcast, 0xff, ETH_ALEN);
> > 
> > Isn't there a statically-allocated array w/ the broadcast MAC in it
> > somewhere already?
> > 
> 
> Not that I could find.
> 
> There are several places in mac80211 where the broadcast MAC is
> created on the fly. None of them would benefit from having a static
> array - one would just substitute memcpy for memset and possibly trash
> the cache.
> 
> There is an array broadcast[MAX_ADDR_LEN] in struct net_device, but it
> would need to be initialized with 0xFF's before usage.
> 
> I still think that b43 needs to create this array, and that the best
> place to do it is in the error path that is unlikely to be executed.

This is not an error path.
Why don't you simply define
	static const u8 bcast_addr[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, };
It has zero runtime overhead and is much easier to understand.
And the linker will merge the arrays, if there are multiple of these arrays
in the compilation unit.

Note that you might need to wrap this into
#if B43_DEBUG
#endif
to avoid a compilation warning on non-debug builds in any case

-- 
Greetings, Michael.
--
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