Search Linux Wireless

Re: [PATCH 2/2] rfkill: use strict_strtoul

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

 



On Sun, 17 Aug 2008, John W. Linville wrote:
> On Sat, Aug 02, 2008 at 02:56:26PM -0300, Henrique de Moraes Holschuh wrote:
> > Switch sysfs parsing to something that actually works properly.
> 
> > @@ -402,7 +410,7 @@ static ssize_t rfkill_claim_store(struct device *dev,
> >  	if (error)
> >  		return error;
> >  
> > -	if (rfkill->user_claim != claim) {
> > +	if (!!rfkill->user_claim != !!claim) {
> >  		if (!claim) {
> >  			mutex_lock(&rfkill->mutex);
> >  			rfkill_toggle_radio(rfkill,
> 
> This looks a bit funny.  Is the '!!' in front of 'rfkill->user_claim'
> really necessary?  Especially since...

It is the safest way (read: it won't go wrong if we change user_claim and
claim types) to do it AFAIK, and the compiled is in charge of optimizing it
properly.

> > @@ -410,7 +418,7 @@ static ssize_t rfkill_claim_store(struct device *dev,
> >  					    0);
> >  			mutex_unlock(&rfkill->mutex);
> >  		}
> > -		rfkill->user_claim = claim;
> > +		rfkill->user_claim = !!claim;
> >  	}
> >  
> >  	mutex_unlock(&rfkill_mutex);
> 
> You seem to be doing the only assignment to 'rfkill->user_claim',
> using a '!!' to condition the input?

user_claim is externally accessible, I thought it best to play safe.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
--
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