linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [RFC] sched: make DECLARE_COMPLETION_ONSTACK() work with clang
@ 2017-02-01 16:34 Arnd Bergmann
  2017-02-01 16:38 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2017-02-01 16:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-mm, Arnd Bergmann, Ingo Molnar

Building with clang, we get a warning for each use of COMPLETION_INITIALIZER_ONSTACK, e.g.:

block/blk-exec.c:103:29: warning: variable 'wait' is uninitialized when used within its own initialization [-Wuninitialized]
include/linux/completion.h:61:58: note: expanded from macro 'DECLARE_COMPLETION_ONSTACK'
include/linux/completion.h:34:29: note: expanded from macro 'COMPLETION_INITIALIZER_ONSTACK'

This seems to be a problem in clang, but it's relatively easy to work around
by changing the assignment.

I filed a bug against clang for the warning, but if we want to support old versions,
we may want this change as well.

I have not yet checked if the new version produces worse object code.

Link: https://llvm.org/bugs/show_bug.cgi?id=31829
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/completion.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/linux/completion.h b/include/linux/completion.h
index fa5d3efaba56..5d5aaae3af43 100644
--- a/include/linux/completion.h
+++ b/include/linux/completion.h
@@ -31,7 +31,7 @@ struct completion {
 	{ 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
 
 #define COMPLETION_INITIALIZER_ONSTACK(work) \
-	(*init_completion(&work))
+	({ init_completion(&work); work; })
 
 /**
  * DECLARE_COMPLETION - declare and initialize a completion structure
@@ -70,11 +70,10 @@ struct completion {
  * This inline function will initialize a dynamically created completion
  * structure.
  */
-static inline struct completion *init_completion(struct completion *x)
+static inline void init_completion(struct completion *x)
 {
 	x->done = 0;
 	init_waitqueue_head(&x->wait);
-	return x;
 }
 
 /**
-- 
2.9.0

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

* Re: [PATCH] [RFC] sched: make DECLARE_COMPLETION_ONSTACK() work with clang
  2017-02-01 16:34 [PATCH] [RFC] sched: make DECLARE_COMPLETION_ONSTACK() work with clang Arnd Bergmann
@ 2017-02-01 16:38 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2017-02-01 16:38 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: linux-mm, Arnd Bergmann, Ingo Molnar

On Wed, Feb 1, 2017 at 5:34 PM, Arnd Bergmann <arnd@arndb.de> wrote:

> diff --git a/include/linux/completion.h b/include/linux/completion.h
> index fa5d3efaba56..5d5aaae3af43 100644
> --- a/include/linux/completion.h
> +++ b/include/linux/completion.h
> @@ -31,7 +31,7 @@ struct completion {
>         { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
>
>  #define COMPLETION_INITIALIZER_ONSTACK(work) \
> -       (*init_completion(&work))
> +       ({ init_completion(&work); work; })
>
>  /**
>   * DECLARE_COMPLETION - declare and initialize a completion structure
> @@ -70,11 +70,10 @@ struct completion {
>   * This inline function will initialize a dynamically created completion
>   * structure.
>   */
> -static inline struct completion *init_completion(struct completion *x)
> +static inline void init_completion(struct completion *x)
>  {
>         x->done = 0;
>         init_waitqueue_head(&x->wait);
> -       return x;
>  }
>

I accidentally submitted the wrong patch, this is the revert of the
actual change.

       Arnd

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

end of thread, other threads:[~2017-02-01 16:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-01 16:34 [PATCH] [RFC] sched: make DECLARE_COMPLETION_ONSTACK() work with clang Arnd Bergmann
2017-02-01 16:38 ` 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).