Re: [PATCH v1] cleanup: adjust scoped_guard() to avoid potential warning
From: Dmitry Torokhov
Date: Thu Oct 03 2024 - 09:00:46 EST
Hi Przemek,
On Thu, Oct 03, 2024 at 01:39:06PM +0200, Przemek Kitszel wrote:
> @@ -167,14 +172,25 @@ static inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \
> CLASS(_name, __UNIQUE_ID(guard))
>
> #define __guard_ptr(_name) class_##_name##_lock_ptr
> +#define __is_cond_ptr(_name) class_##_name##_is_conditional
> +
> +#define __scoped_guard_labeled(_label, _name, args...) \
> + for (CLASS(_name, scope)(args); \
> + __guard_ptr(_name)(&scope) || !__is_cond_ptr(_name); \
It would be great if you added the comment that "!__is_cond_ptr(_name)"
condition ensures that the compiler does not believe that it is possible
to skip the loop body because it does not realize that
"__guard_ptr(_name)(&scope)" will never return 0 for unconditional
locks. You have the explanation in the patch description, but I think it
is worth to reiterate here as well.
> + ({ goto _label; })) \
> + if (0) \
> + _label: \
> + break; \
> + else
> +
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
Thanks.
--
Dmitry