Re: [PATCH v4] cleanup: adjust scoped_guard() macros to avoid potential warning

From: Peter Zijlstra
Date: Wed Oct 23 2024 - 06:27:24 EST


On Fri, Oct 18, 2024 at 12:15:50PM -0700, Dmitry Torokhov wrote:
> Hi Przemek,
>
> On Fri, Oct18, 2024 at 01:38:14PM +0200, Przemek Kitszel wrote:
> > Change scoped_guard() and scoped_cond_guard() macros to make reasoning
> > about them easier for static analysis tools (smatch, compiler
> > diagnostics), especially to enable them to tell if the given usage of
> > scoped_guard() is with a conditional lock class (interruptible-locks,
> > try-locks) or not (like simple mutex_lock()).
>
> Thank you for making all these improvements!
>
> >
> > +#define __DEFINE_CLASS_IS_CONDITIONAL(_name, _is_cond) \
> > +static __maybe_unused const bool class_##_name##_is_conditional = _is_cond
>
> Question - does this have to be a constant or can it be a macro?

One macro cannot define another.