Re: [patch V3 10/18] posix-timers: Make lock_timer() use guard()
From: Frederic Weisbecker
Date: Mon Mar 10 2025 - 18:16:12 EST
Le Mon, Mar 10, 2025 at 06:36:18PM +0100, Thomas Gleixner a écrit :
> On Mon, Mar 10 2025 at 12:57, Frederic Weisbecker wrote:
> > Le Sat, Mar 08, 2025 at 05:48:34PM +0100, Thomas Gleixner a écrit :
> >> --- a/kernel/time/posix-timers.c
> >> +++ b/kernel/time/posix-timers.c
> >> @@ -63,9 +63,18 @@ static struct k_itimer *__lock_timer(tim
> >>
> >> static inline void unlock_timer(struct k_itimer *timr)
> >> {
> >> - spin_unlock_irq(&timr->it_lock);
> >> + if (likely((timr)))
> >> + spin_unlock_irq(&timr->it_lock);
> >> }
> >>
> >> +#define scoped_timer_get_or_fail(_id) \
> >> + scoped_cond_guard(lock_timer, return -EINVAL, _id)
> >
> > I'm not really fond of the fact this hides a return.
>
> I could drop the macro and let the call sites all do:
>
> scoped_cond_guard(lock_timer, return -EINVAL, $d)
>
> But I'm not sure it's much better :)
Nah let's just keep it as is, until we ever find a better idea :-)