[LinuxPPS] [PATCHv4 10/17] pps: use BUG_ON for kernel API safety checks

Rodolfo Giometti giometti at enneenne.com
Sat Nov 20 19:30:07 CET 2010


On Sat, Nov 20, 2010 at 09:01:41AM -0800, Joe Perches wrote:
> > > -	if ((event & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR)) == 0) {
> > > -		dev_err(pps->dev, "unknown event (%x)\n", event);
> > > -		return;
> > > -	}
> > > +	/* check event type */
> > > +	BUG_ON((event & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR)) == 0);
> > 
> > Ack.
> > 
> > This is a correct usage of BUG_ON. :)
> 
> I don't think that's true.
> 
> /*
>  * Don't use BUG() or BUG_ON() unless there's really no way out; one
>  * example might be detecting data structure corruption in the middle
>  * of an operation that can't be backed out of.  If the (sub)system
>  * can somehow continue operating, perhaps with reduced functionality,
>  * it's probably not BUG-worthy.
>  *
>  * If you're tempted to BUG(), think again:  is completely giving up
>  * really the *only* solution?  There are usually better options, where
>  * users don't need to reboot ASAP and can mostly shut down cleanly.
>  */

If (event & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR)) == 0 then PPS's
data has been corrupted. The PPS subsystem doesn't work correctly even
if the whole system still continues running.

However I already have not acknowledged the patch.

Ciao,

Rodolfo

-- 

GNU/Linux Solutions                  e-mail: giometti at enneenne.com
Linux Device Driver                          giometti at linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it



More information about the LinuxPPS mailing list