Re: ✗ Fi.CI.CHECKPATCH: warning for use dynamic-debug under drm.debug api (rev2)

jim.cromie at gmail.com jim.cromie at gmail.com
Fri Mar 4 21:56:55 UTC 2022


On Tue, Mar 1, 2022 at 1:57 PM Patchwork
<patchwork at emeril.freedesktop.org> wrote:
>
> == Series Details ==
>
> Series: use dynamic-debug under drm.debug api (rev2)
> URL   : https://patchwork.freedesktop.org/series/100289/
> State : warning
>
> == Summary ==
>
> $ dim checkpatch origin/drm-tip
> c2ed9cc02d9c dyndbg: fix static_branch manipulation
> a8f6c71f283e dyndbg: add class_id field and query support
> -:141: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'id' - possible side-effects?
> #141: FILE: include/linux/dynamic_debug.h:142:
> +#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do {  \
> +       DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt);        \
> +       if (DYNAMIC_DEBUG_BRANCH(id))                           \
> +               func(&id, ##__VA_ARGS__);                       \
>  } while (0)
>
> -:151: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'id' - possible side-effects?
> #151: FILE: include/linux/dynamic_debug.h:148:
> +#define __dynamic_func_call_no_desc_cls(id, cls, fmt, func, ...) do {  \
> +       DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt);                \
> +       if (DYNAMIC_DEBUG_BRANCH(id))                                   \
> +               func(__VA_ARGS__);                                      \
>  } while (0)
>

Can I get a pass on this ?

the usual approach doesnt work:
+       typeof(id) id = (id);           \

it appears to be due to the outer / wrapping macro inserting the
__UNIQUE_ID(ddebug)
which gets expanded 2x, giving:

      |         ^~~~~~~~
/home/jimc/projects/lx/linux.git/include/linux/compiler-gcc.h:42:45:
note: previous definition of ‘__UNIQUE_ID_ddebug437’ with type ‘int’
   42 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_,
prefix), __COUNTER__)
      |                                             ^~~~~~~~~~~~
/home/jimc/projects/lx/linux.git/include/linux/dynamic_debug.h:230:20:
note: in definition of macro ‘__dynamic_func_call_cls’
  230 |         typeof(id) id = (id);           \


Moreover, these 2 macros imitate existing macros,
which would suffer the same WARNING.

My macro-fu is insufficient,
can anyone suggest a clean way to fix this warning ?

tia
Jim


More information about the dri-devel mailing list