[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241018105054.GB36494@noisy.programming.kicks-ass.net>
Date: Fri, 18 Oct 2024 12:50:54 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: kernel test robot <lkp@...el.com>
Cc: Przemek Kitszel <przemyslaw.kitszel@...el.com>,
linux-kernel@...r.kernel.org, llvm@...ts.linux.dev,
oe-kbuild-all@...ts.linux.dev, 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 <keescook@...omium.org>,
David Lechner <dlechner@...libre.com>,
Dan Carpenter <error27@...il.com>,
Andy Shevchenko <andriy.shevchenko@...el.com>,
Dmitry Torokhov <dmitry.torokhov@...il.com>
Subject: Re: [PATCH v3] cleanup: adjust scoped_guard() macros to avoid
potential warning
On Sun, Oct 13, 2024 at 12:01:24PM +0800, kernel test robot wrote:
> >> drivers/firewire/core-transaction.c:912:2: warning: variable 'handler' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
> 912 | scoped_guard(rcu) {
> | ^~~~~~~~~~~~~~~~~
> include/linux/cleanup.h:197:2: note: expanded from macro 'scoped_guard'
> 197 | __scoped_guard(_name, /* empty */, __UNIQUE_ID(label), args)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/cleanup.h:190:3: note: expanded from macro '__scoped_guard'
> 190 | if (!__guard_ptr(_name)(&scope) && __is_cond_ptr(_name)) { \
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/compiler.h:55:28: note: expanded from macro 'if'
> 55 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/compiler.h:57:30: note: expanded from macro '__trace_if_var'
> 57 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/firewire/core-transaction.c:921:7: note: uninitialized use occurs here
> 921 | if (!handler)
> | ^~~~~~~
> include/linux/compiler.h:55:47: note: expanded from macro 'if'
> 55 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
> | ^~~~
> include/linux/compiler.h:57:52: note: expanded from macro '__trace_if_var'
> 57 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
> | ^~~~
> drivers/firewire/core-transaction.c:912:2: note: remove the 'if' if its condition is always false
> 912 | scoped_guard(rcu) {
> | ^
> include/linux/cleanup.h:197:2: note: expanded from macro 'scoped_guard'
> 197 | __scoped_guard(_name, /* empty */, __UNIQUE_ID(label), args)
> | ^
> include/linux/cleanup.h:190:3: note: expanded from macro '__scoped_guard'
> 190 | if (!__guard_ptr(_name)(&scope) && __is_cond_ptr(_name)) { \
> | ^
> include/linux/compiler.h:55:23: note: expanded from macro 'if'
> 55 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
> | ^
> drivers/firewire/core-transaction.c:903:36: note: initialize the variable 'handler' to silence this warning
> 903 | struct fw_address_handler *handler;
> | ^
> | = NULL
> 1 warning generated.
So this goes away when we do:
--- a/include/linux/cleanup.h
+++ b/include/linux/cleanup.h
@@ -323,7 +323,7 @@ static __maybe_unused const bool class_#
*/
#define __scoped_guard(_name, _fail, _label, args...) \
for (CLASS(_name, scope)(args); true; ({ goto _label; })) \
- if (!__guard_ptr(_name)(&scope) && __is_cond_ptr(_name)) { \
+ if (__is_cond_ptr(_name) && !__guard_ptr(_name)(&scope)) { \
_fail; \
_label: \
break; \
Powered by blists - more mailing lists