linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lockdep: avoid bogus clang warning
@ 2019-03-25 12:57 Arnd Bergmann
  2019-03-25 13:12 ` Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arnd Bergmann @ 2019-03-25 12:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Will Deacon
  Cc: clang-built-linux, Nick Desaulniers, Nathan Chancellor,
	Arnd Bergmann, Bart Van Assche, Waiman Long,
	Joel Fernandes (Google), Steven Rostedt (VMware),
	linux-kernel

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)
 
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] lockdep: avoid bogus clang warning
  2019-03-25 12:57 [PATCH] lockdep: avoid bogus clang warning Arnd Bergmann
@ 2019-03-25 13:12 ` Steven Rostedt
  2019-04-03 12:44 ` Will Deacon
  2019-04-18 12:04 ` [tip:locking/core] locking/lockdep: Avoid bogus Clang warning tip-bot for Arnd Bergmann
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2019-03-25 13:12 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, clang-built-linux,
	Nick Desaulniers, Nathan Chancellor, Bart Van Assche,
	Waiman Long, Joel Fernandes (Google),
	linux-kernel

On Mon, 25 Mar 2019 13:57:57 +0100
Arnd Bergmann <arnd@arndb.de> 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);
>                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Sad it warns as struct pin_cookie is of size zero. But hey.

>  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; })

Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

>  #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)
>  


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lockdep: avoid bogus clang warning
  2019-03-25 12:57 [PATCH] lockdep: avoid bogus clang warning Arnd Bergmann
  2019-03-25 13:12 ` Steven Rostedt
@ 2019-04-03 12:44 ` Will Deacon
  2019-04-18 12:04 ` [tip:locking/core] locking/lockdep: Avoid bogus Clang warning tip-bot for Arnd Bergmann
  2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2019-04-03 12:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Peter Zijlstra, Ingo Molnar, clang-built-linux, Nick Desaulniers,
	Nathan Chancellor, Bart Van Assche, Waiman Long,
	Joel Fernandes (Google), Steven Rostedt (VMware),
	linux-kernel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:locking/core] locking/lockdep: Avoid bogus Clang warning
  2019-03-25 12:57 [PATCH] lockdep: avoid bogus clang warning Arnd Bergmann
  2019-03-25 13:12 ` Steven Rostedt
  2019-04-03 12:44 ` Will Deacon
@ 2019-04-18 12:04 ` tip-bot for Arnd Bergmann
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Arnd Bergmann @ 2019-04-18 12:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, linux-kernel, joel, longman, arnd, natechancellor, peterz,
	hpa, rostedt, will.deacon, torvalds, tglx, ndesaulniers,
	bvanassche

Commit-ID:  3771b0fe9dfc3801eac0142d1af6ba94dee83c6c
Gitweb:     https://git.kernel.org/tip/3771b0fe9dfc3801eac0142d1af6ba94dee83c6c
Author:     Arnd Bergmann <arnd@arndb.de>
AuthorDate: Mon, 25 Mar 2019 13:57:57 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 18 Apr 2019 14:01:17 +0200

locking/lockdep: Avoid bogus Clang warning

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>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nathan Chancellor <natechancellor@gmail.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Waiman Long <longman@redhat.com>
Cc: clang-built-linux@googlegroups.com
Link: http://lkml.kernel.org/r/20190325125807.1437049-1-arnd@arndb.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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..21725a91442b 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)
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-18 12:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-25 12:57 [PATCH] lockdep: avoid bogus clang warning Arnd Bergmann
2019-03-25 13:12 ` Steven Rostedt
2019-04-03 12:44 ` Will Deacon
2019-04-18 12:04 ` [tip:locking/core] locking/lockdep: Avoid bogus Clang warning tip-bot for Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).