mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	clang-built-linux@googlegroups.com,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nathan Chancellor <natechancellor@gmail.com>,
	Bart Van Assche <bvanassche@acm.org>,
	Waiman Long <longman@redhat.com>,
	"Joel Fernandes (Google)" <joel@joelfernandes.org>,
	"Steven Rostedt (VMware)" <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lockdep: avoid bogus clang warning
Date: Wed, 3 Apr 2019 13:44:02 +0100	[thread overview]
Message-ID: <20190403124402.GD16362@fuggles.cambridge.arm.com> (raw)
In-Reply-To: <20190325125807.1437049-1-arnd@arndb.de>

On Mon, Mar 25, 2019 at 01:57:57PM +0100, Arnd Bergmann wrote:
> When lockdep is enabled, and -Wuninitialized warnings are enabled,
> clang produces a silly warning for every file we compile:
> 
> In file included from  kernel/sched/fair.c:23:
>  kernel/sched/sched.h:1094:15: error: variable 'cookie' is uninitialized when used here [-Werror,-Wuninitialized]
>         rf->cookie = lockdep_pin_lock(&rq->lock);
>                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>  include/linux/lockdep.h:474:60: note: expanded from macro 'lockdep_pin_lock'
>  #define lockdep_pin_lock(l)                     ({ struct pin_cookie cookie; cookie; })
>                                                                              ^~~~~~
>  kernel/sched/sched.h:1094:15: note: variable 'cookie' is declared here
>  include/linux/lockdep.h:474:34: note: expanded from macro 'lockdep_pin_lock'
>  #define lockdep_pin_lock(l)                     ({ struct pin_cookie cookie; cookie; })
>                                                    ^
> As the 'struct pin_cookie' structure is empty in this configuration,
> there is no need to initialize it for correctness, but it also
> does not hurt to set it to an empty structure, so do that to
> avoid the warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  include/linux/lockdep.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
> index 79c3873d58ac..31d7549933eb 100644
> --- a/include/linux/lockdep.h
> +++ b/include/linux/lockdep.h
> @@ -471,7 +471,7 @@ struct pin_cookie { };
>  
>  #define NIL_COOKIE (struct pin_cookie){ }
>  
> -#define lockdep_pin_lock(l)			({ struct pin_cookie cookie; cookie; })
> +#define lockdep_pin_lock(l)			({ struct pin_cookie cookie = {}; cookie; })
>  #define lockdep_repin_lock(l, c)		do { (void)(l); (void)(c); } while (0)
>  #define lockdep_unpin_lock(l, c)		do { (void)(l); (void)(c); } while (0)

Acked-by: Will Deacon <will.deacon@arm.com>

Will

  parent reply	other threads:[~2019-04-03 12:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-25 12:57 Arnd Bergmann
2019-03-25 13:12 ` Steven Rostedt
2019-04-03 12:44 ` Will Deacon [this message]
2019-04-18 12:04 ` [tip:locking/core] locking/lockdep: Avoid bogus Clang warning tip-bot for Arnd Bergmann

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=20190403124402.GD16362@fuggles.cambridge.arm.com \
    --to=will.deacon@arm.com \
    --cc=arnd@arndb.de \
    --cc=bvanassche@acm.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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

Powered by JetHome