lkml.org 
[lkml]   [2010]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCHv4 10/17] pps: use BUG_ON for kernel API safety checks
On Sun, Nov 21, 2010 at 03:40:08AM +0300, Alexander Gordeev wrote:
> ?? Sat, 20 Nov 2010 09:01:41 -0800
> Joe Perches <joe@perches.com> ??????????:
>
> > On Sat, 2010-11-20 at 17:13 +0100, Rodolfo Giometti wrote:
> > > On Thu, Nov 18, 2010 at 07:01:03PM +0300, Alexander Gordeev wrote:
> > > > This way less overhead is involved when running production kernel.
> > > > If you want to debug a pps client module please define DEBUG to enable
> > > > the checks.
> > > > Signed-off-by: Alexander Gordeev <lasaine@lvk.cs.msu.su>
> > []
> > > > diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c
> > > > @@ -179,10 +168,8 @@ void pps_event(struct pps_device *pps, struct pps_event_time *ts, int event,
> > > > int captured = 0;
> > > > struct pps_ktime ts_real;
> > > >
> > > > - 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.
> > */
>
> Hmm, didn't check that before. What is more appropriate in this
> situation?

IMHO here you can use BUG_ON() but not into pps_register_source().

Ciao,

Rodolfo

--

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


\
 
 \ /
  Last update: 2010-11-21 09:45    [W:0.068 / U:6.868 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site