sched: make DECLARE_COMPLETION_ONSTACK() work with clang
RFC PATCH v2 1/1 sched: make DECLARE_COMPLETION_ONSTACK() work with clang
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.
---
v2: send the correct patch
--- include/linux/completion.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/linux/completion.h +3 -2
@@ -31,7 +31,7 @@ struct completion { { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }#define COMPLETION_INITIALIZER_ONSTACK (work) \ - ({ init_completion(&work); work; }) + (*init_completion(&work))/** * DECLARE_COMPLETION - declare and initialize a completion structure
@@ -70,10 +70,11 @@ struct completion {* This inline function will initialize a dynamically created completion * structure. */ -static inline void init_completion (struct completion *x) +static inline struct completion *init_completion (struct completion *x) { x->done =0 ;init_waitqueue_head (&x->wait); +return x; }/**
Signature · 7 lines
2.9.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>