LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] Change wait_for_completion_*_timeout to return a signed long
@ 2011-01-05  1:50 NeilBrown
  2011-01-05 14:07 ` [tip:sched/core] sched: Change wait_for_completion_*_timeout() " tip-bot for NeilBrown
  2011-01-05 22:57 ` [PATCH] Change wait_for_completion_*_timeout " Andrew Morton
  0 siblings, 2 replies; 7+ messages in thread
From: NeilBrown @ 2011-01-05  1:50 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Thomas Gleixner, J. Bruce Fields


wait_for_completion_*_timeout can return:

 0 if the wait timed out
 -ve if the wait was interrupted
 +ve if the completion was completed.

As they currently return an 'unsigned long', the last two cases are not
easily distinguished which can easily result in buggy code, as is the
case for the recently added wait_for_completion_interruptible_timeout
call in net/sunrpc/cache.c

So change them both to return 'long'.  As MAX_SCHEDULE_TIMEOUT is
LONG_MAX, a large +ve return value should never overflow.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/include/linux/completion.h b/include/linux/completion.h
index 36d57f7..142fe6f 100644
--- a/include/linux/completion.h
+++ b/include/linux/completion.h
@@ -80,11 +80,11 @@ extern void wait_for_completion(struct completion *);
 extern int wait_for_completion_interruptible(struct completion *x);
 extern int wait_for_completion_killable(struct completion *x);
 extern unsigned long wait_for_completion_timeout(struct completion *x,
 						   unsigned long timeout);
-extern unsigned long wait_for_completion_interruptible_timeout(
-			struct completion *x, unsigned long timeout);
-extern unsigned long wait_for_completion_killable_timeout(
-			struct completion *x, unsigned long timeout);
+extern long wait_for_completion_interruptible_timeout(
+	struct completion *x, unsigned long timeout);
+extern long wait_for_completion_killable_timeout(
+	struct completion *x, unsigned long timeout);
 extern bool try_wait_for_completion(struct completion *x);
 extern bool completion_done(struct completion *x);
 
diff --git a/kernel/sched.c b/kernel/sched.c
index 297d1a0..8f35baf 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4526,7 +4526,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
  * This waits for either a completion of a specific task to be signaled or for a
  * specified timeout to expire. It is interruptible. The timeout is in jiffies.
  */
-unsigned long __sched
+long __sched
 wait_for_completion_interruptible_timeout(struct completion *x,
 					  unsigned long timeout)
 {
@@ -4559,7 +4559,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
  * signaled or for a specified timeout to expire. It can be
  * interrupted by a kill signal. The timeout is in jiffies.
  */
-unsigned long __sched
+long __sched
 wait_for_completion_killable_timeout(struct completion *x,
 				     unsigned long timeout)
 {

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

end of thread, other threads:[~2011-02-15 16:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-05  1:50 [PATCH] Change wait_for_completion_*_timeout to return a signed long NeilBrown
2011-01-05 14:07 ` [tip:sched/core] sched: Change wait_for_completion_*_timeout() " tip-bot for NeilBrown
2011-01-11 21:44   ` J. Bruce Fields
2011-01-11 22:07     ` NeilBrown
2011-02-15 16:20       ` [stable] " Greg KH
2011-01-05 22:57 ` [PATCH] Change wait_for_completion_*_timeout " Andrew Morton
2011-01-06  0:33   ` NeilBrown

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