Re: [PATCH] staging: rtl8723bs: do not use assignment in if condition

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

 



On Fri, 2018-06-22 at 13:40 +0300, Dan Carpenter wrote:
> On Thu, Jun 21, 2018 at 08:22:30PM +0200, Michael Straube wrote:
> > Fix checkpatch error 'do not use assignment in if condition'.
[]
> > diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
> > index e55895632921..87a4ced41028 100644
> > --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
> > +++ b/ 
> > @@ -1181,9 +1181,8 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr)
> >  	     (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) ||
> >  	    ((mac[0] == 0x00) && (mac[1] == 0x00) && (mac[2] == 0x00) &&
> >  	     (mac[3] == 0x00) && (mac[4] == 0x00) && (mac[5] == 0x00))) {

Should also use is_broadcast_ether_addr and is_zero_ether_addr

> > -		if (np &&
> > -		    (addr = of_get_property(np, "local-mac-address", &len)) &&
> > -		    len == ETH_ALEN) {
> > +		addr = of_get_property(np, "local-mac-address", &len);
> > +		if (np && addr && len == ETH_ALEN) {
> 
> You can remove the "np" check.
> 
> 		if (addr && len == ETH_ALEN) {

It looks more like the rewrite is incorrect
as np is tested before of_get_property

It could be written something like:

	if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) {
		bool assigned = false;

		if (np) {
			addr = of_get_property(np, "local-mac-address", &len);
			if (len == ETH_ALEN) {
				memcpy(mac_addr, addr, ETH_ALEN);
				assigned = true;
			}
		}
		if (!assigned) {
			mac_addr[0] = 0x00;
			mac_addr[1] = ...
		}
	}
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux