[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1431011084-29177-1-git-send-email-hofrat@osadl.org>
Date: Thu, 7 May 2015 17:04:44 +0200
From: Nicholas Mc Guire <hofrat@...dl.org>
To: Ingo Molnar <mingo@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
linux-kernel@...r.kernel.org, Nicholas Mc Guire <hofrat@...dl.org>
Subject: [PATCH RFC] sched/completion: match return type to function signatures
try_wait_for_completion is declared bool but returns int,
wait_for_completion_interruptible is declared int but can return long
wait_for_completion_killable also is declared int but can return long
to resolve this return types and/or return statements are fixed up.
Signed-off-by: Nicholas Mc Guire <hofrat@...dl.org>
---
type-checking kernel functions with some experimental coccinelle spatches
gave me:
HANDLING: kernel/sched/completion.c
kernel/sched/completion.c:192 WARNING: return of wrong type - int != long,
kernel/sched/completion.c:229 WARNING: return of wrong type - int != long,
kernel/sched/completion.c:286 WARNING: return of wrong type - bool != int,
this patch fixes up these type mismatches.
Not sure if such "type cleanups" are wanted - there are quite a few of them
many might be considered benign though type mismatches can lead to quite
hard to locate issues. If this makes sense to clean up such mismatches
then a few more patches will follow, pleas let me know.
Patch was compile tested with x86_64_defconfig
Patch is against 4.1-rc2 (localversion-next is -next-20150506)
kernel/sched/completion.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index 8d0f35d..0b97a10 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -189,7 +189,7 @@ int __sched wait_for_completion_interruptible(struct completion *x)
{
long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_INTERRUPTIBLE);
if (t == -ERESTARTSYS)
- return t;
+ return -ERESTARTSYS;
return 0;
}
EXPORT_SYMBOL(wait_for_completion_interruptible);
@@ -226,7 +226,7 @@ int __sched wait_for_completion_killable(struct completion *x)
{
long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
if (t == -ERESTARTSYS)
- return t;
+ return -ERESTARTSYS;
return 0;
}
EXPORT_SYMBOL(wait_for_completion_killable);
@@ -266,7 +266,7 @@ EXPORT_SYMBOL(wait_for_completion_killable_timeout);
bool try_wait_for_completion(struct completion *x)
{
unsigned long flags;
- int ret = 1;
+ bool ret = true;
/*
* Since x->done will need to be locked only
@@ -275,11 +275,11 @@ bool try_wait_for_completion(struct completion *x)
* return early in the blocking case.
*/
if (!READ_ONCE(x->done))
- return 0;
+ return false;
spin_lock_irqsave(&x->wait.lock, flags);
if (!x->done)
- ret = 0;
+ ret = false;
else
x->done--;
spin_unlock_irqrestore(&x->wait.lock, flags);
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists