Search Linux Wireless

Re: [PATCH] rfkill: add master_switch_mode functionality

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

 



On Wed, 23 Jul 2008, Ivo van Doorn wrote:
> > +enum rfkill_input_master_mode {
> > +	RFKILL_INPUT_MASTER_DONOTHING = 0,
> > +	RFKILL_INPUT_MASTER_RESTORE = 1,
> > +	RFKILL_INPUT_MASTER_UNBLOCKALL = 2,
> 
> RFKILL_INPUT_MASTER_LAST, /* Internal */
> 
> See below for reason. :)

[...]

> >  static int __init rfkill_handler_init(void)
> >  {
> > +	switch (rfkill_master_switch_mode) {
> > +	case RFKILL_INPUT_MASTER_DONOTHING:
> > +	case RFKILL_INPUT_MASTER_RESTORE:
> > +	case RFKILL_INPUT_MASTER_UNBLOCKALL:
> > +		break;
> > +	default:
> > +		return -EINVAL;
> > +	}
> 
> if (rfkill_master_switch_mode >= RFKILL_INPUT_MASTER_LAST)
> 	return -EINVAL

It will generate the same code :-)  I can certainly do it that way, but if I
do, every switch() statement will HAVE to handle either default or
RFKILL_INPUT_MASTER_LAST...  which is bad, as you don't get the warning that
you forgot to handle something in other code paths that don't need default:
handling.

That reminds me that I should kill the default: clause in
rfkill_schedule_evsw_rfkillall().  It is there because an earlier version of
the patch would let userspace modify the module paramenter.  That didn't
play out well (if we want to do that, we should do it in some other way),
and I forgot to remove the default handling when I made the attribute
read-only.

> This will make sure new entries in the enum are automatically handled.
> Note that your next patch doesn't update the above switch statement,

My next patch doesn't deal with RFKILL_INPUT_MASTER_* :-) I guess you
misread.

-- 
  "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