[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a2358981-289b-4fee-854b-ca6e9fd8b2e6@intel.com>
Date: Thu, 3 Oct 2024 15:42:20 +0200
From: Przemek Kitszel <przemyslaw.kitszel@...el.com>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>
CC: <linux-kernel@...r.kernel.org>, <amadeuszx.slawinski@...ux.intel.com>,
Tony Nguyen <anthony.l.nguyen@...el.com>,
<nex.sw.ncis.osdt.itp.upstreaming@...el.com>, <netdev@...r.kernel.org>,
Markus Elfring <Markus.Elfring@....de>, Kees Cook <kees@...nel.org>, "Dan
Carpenter" <dan.carpenter@...aro.org>, Peter Zijlstra <peterz@...radead.org>,
Andy Shevchenko <andriy.shevchenko@...el.com>
Subject: Re: [PATCH v1] cleanup: adjust scoped_guard() to avoid potential
warning
On 10/3/24 15:00, Dmitry Torokhov wrote:
> 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.
thanks, I will add an in-code comment; sometimes it's easy to loose
outside perspective if you spend too much time on one piece
>
>> + ({ goto _label; })) \
>> + if (0) \
>> + _label: \
>> + break; \
>> + else
>> +
>
> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@...il.com>
>
> Thanks.
>
Powered by blists - more mailing lists