[dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure

David Marchand david.marchand at redhat.com
Wed Jun 26 13:39:20 CEST 2019


On Wed, Jun 26, 2019 at 1:36 PM Thomas Monjalon <thomas at monjalon.net> wrote:

> 26/06/2019 13:20, David Marchand:
> > On Wed, Jun 26, 2019 at 12:41 PM Thomas Monjalon <thomas at monjalon.net>
> > wrote:
> >
> > > When adding an alarm, if an error happen when registering
> > > the common alarm callback, it is not considered as a major failure.
> > > The alarm is then inserted in the list.
> > > However it was returning an error code after inserting the alarm.
> > >
> > > The error code is reset to 0 so the behaviour and the return code
> > > are consistent.
> > > Other return code related lines are cleaned up for easier
> understanding.
> > >
> [...]
> > > --- a/lib/librte_eal/linux/eal/eal_alarm.c
> > > +++ b/lib/librte_eal/linux/eal/eal_alarm.c
> > >         if (!handler_registered) {
> > > -               ret |= rte_intr_callback_register(&intr_handle,
> > > +               ret = rte_intr_callback_register(&intr_handle,
> > >                                 eal_alarm_callback, NULL);
> > > -               handler_registered = (ret == 0) ? 1 : 0;
> > > +               if (ret == 0)
> > > +                       handler_registered = 1;
> > > +               else
> > > +                       /* not fatal, callback can be registered later
> */
> > > +                       ret = 0;
> > >         }
> >
> > Well, then it means that you don't want to touch ret at all.
> > How about:
> > if (rte_intr_callback_register(&intr_handle,
> >                                eal_alarm_callback, NULL) == 0)
> >         handler_registered = 1;
> >
> > ?
>
> Too much simple :)
>
> I think we try to avoid calling a function in a "if"
> per coding style.
> And my proposal has the benefit of offering a comment
> about the non-fatal error.
>

/* not fatal, callback can be registered later */
if (rte_intr_callback_register(&intr_handle,
                              eal_alarm_callback, NULL) == 0)
       handler_registered = 1;



> After saying these arguments, I have to say I have no strong opinion :)
> I'm fine either way.
>

Reviewed-by: David Marchand <david.marchand at redhat.com>
I won't insist either, if you feel like taking my proposal, you can keep
the reviewed-by token.


-- 
David Marchand


More information about the dev mailing list