sched/wait: Explain the shadowing and type inconsistencies
tip-bot for Peter Zijlstra
merge botCommit-ID: 27e4f9d0012a9bb7011aade862f08679d2921ab0 Gitweb: http://git.kernel.org/tip/27e4f9d0012a9bb7011aade862f08679d2921ab0 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 9 Apr 2014 12:50:34 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 18 Apr 2014 12:07:22 +0200
sched/wait: Explain the shadowing and type inconsistencies
Stick in a comment before someone else tries to fix the sparse warning this generates.
Requested-by Andrew Morton <[email protected]>
Signed-off-by Peter Zijlstra <[email protected]>
Cc Linus Torvalds <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- include/linux/wait.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
include/linux/wait.h +13 -1
@@ -191,11 +191,23 @@ wait_queue_head_t *bit_waitqueue(void *, int); (!__builtin_constant_p (state) || \ state ==TASK_INTERRUPTIBLE || state ==TASK_KILLABLE ) \ +/* +* The below macro ___wait_event() has an explicit shadow of the __ret +* variable when used from the wait_event_*() macros. +* +* This is so that both can use the ___wait_cond_timeout() construct +* to wrap the condition. +* +* The type inconsistency of the wait_event_*() __ret variable is also +* on purpose; we use long where we can return timeout values and int +* otherwise. + */ +#define ___wait_event (wq, condition, state, exclusive, ret, cmd) \ ({ \ __label__ __out; \ wait_queue_t __wait; \ - long __ret = ret; \ + long __ret = ret;/* explicit shadow */ \ \INIT_LIST_HEAD (&__wait.task_list); \if (exclusive) \