Thread (16 messages) 16 messages, 5 authors, 2024-10-07

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

From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Date: 2024-10-03 13:42:36
Also in: lkml

On 10/3/24 15:00, Dmitry Torokhov wrote:
Hi Przemek,

On Thu, Oct 03, 2024 at 01:39:06PM +0200, Przemek Kitszel wrote:
quoted
@@ -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
quoted
+		     ({ goto _label; }))				\
+		if (0)							\
+		_label:							\
+			break;						\
+		else
+
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Thanks.
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help