From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: <linux-kernel@vger.kernel.org>, <llvm@lists.linux.dev>,
<oe-kbuild-all@lists.linux.dev>,
<amadeuszx.slawinski@linux.intel.com>,
"Tony Nguyen" <anthony.l.nguyen@intel.com>,
<nex.sw.ncis.osdt.itp.upstreaming@intel.com>,
<netdev@vger.kernel.org>, Markus Elfring <Markus.Elfring@web.de>,
Kees Cook <keescook@chromium.org>,
David Lechner <dlechner@baylibre.com>,
Dan Carpenter <error27@gmail.com>,
Andy Shevchenko <andriy.shevchenko@intel.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v3] cleanup: adjust scoped_guard() macros to avoid potential warning
Date: Wed, 23 Oct 2024 15:43:22 +0200 [thread overview]
Message-ID: <a7eec76f-1fbc-4fef-9b6d-15b588eacecb@intel.com> (raw)
In-Reply-To: <20241018105054.GB36494@noisy.programming.kicks-ass.net>
On 10/18/24 12:50, Peter Zijlstra wrote:
> 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)) { \
but this will purge the attempt to call __guard_ptr(), and thus newer
lock ;) good that there is at least some comment above
FTR, I have resolved this via v4
https://lore.kernel.org/netdev/20241018113823.171256-1-przemyslaw.kitszel@intel.com/T/
> _fail; \
> _label: \
> break; \
next prev parent reply other threads:[~2024-10-23 13:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241011121535.28049-1-przemyslaw.kitszel@intel.com>
2024-10-13 4:01 ` [PATCH v3] cleanup: adjust scoped_guard() macros to avoid potential warning kernel test robot
2024-10-18 10:50 ` Peter Zijlstra
2024-10-23 13:43 ` Przemek Kitszel [this message]
2024-10-23 14:32 ` Peter Zijlstra
2024-10-23 14:44 ` Przemek Kitszel
2024-10-13 5:16 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a7eec76f-1fbc-4fef-9b6d-15b588eacecb@intel.com \
--to=przemyslaw.kitszel@intel.com \
--cc=Markus.Elfring@web.de \
--cc=amadeuszx.slawinski@linux.intel.com \
--cc=andriy.shevchenko@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=dlechner@baylibre.com \
--cc=dmitry.torokhov@gmail.com \
--cc=error27@gmail.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=nex.sw.ncis.osdt.itp.upstreaming@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox