lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1490277945-22429-1-git-send-email-der.herr@hofr.at>
Date:   Thu, 23 Mar 2017 15:05:45 +0100
From:   Nicholas Mc Guire <der.herr@...r.at>
To:     Ingo Molnar <mingo@...hat.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Oleg Nesterov <oleg@...hat.com>, linux-kernel@...r.kernel.org,
        Nicholas Mc Guire <der.herr@...r.at>
Subject: [PATCH] sched/completions: use true/false for bool returns

Use true/false for bool rather than 1|0 both in the code and the 
documentation

Signed-off-by: Nicholas Mc Guire <der.herr@...r.at>
---

Found by coccinelle: boolreturn.cocci complains about
./kernel/sched/completion.c:281:9-10: WARNING: return of 0/1 in function 'try_wait_for_completion' with return type bool
in addition the int type should also be a bool here and assigned 
appropriately along with fixing up the documentation.
completion_done() was using true/false but the header still was showing
0|1 - so fix up the header to reflect the bool type there as well.

Patch was compile tested with: x86_64_defconfig

Patch is against 4.11-rc3 (localversion-next is next-20170323)

 kernel/sched/completion.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index 53f9558..ef92b15 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -258,8 +258,8 @@ EXPORT_SYMBOL(wait_for_completion_killable_timeout);
  *	try_wait_for_completion - try to decrement a completion without blocking
  *	@x:	completion structure
  *
- *	Return: 0 if a decrement cannot be done without blocking
- *		 1 if a decrement succeeded.
+ *	Return: false if a decrement cannot be done without blocking
+ *		 true if a decrement succeeded.
  *
  *	If a completion is being used as a counting completion,
  *	attempt to decrement the counter without blocking. This
@@ -269,7 +269,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
@@ -278,11 +278,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 if (x->done != UINT_MAX)
 		x->done--;
 	spin_unlock_irqrestore(&x->wait.lock, flags);
@@ -294,8 +294,8 @@ EXPORT_SYMBOL(try_wait_for_completion);
  *	completion_done - Test to see if a completion has any waiters
  *	@x:	completion structure
  *
- *	Return: 0 if there are waiters (wait_for_completion() in progress)
- *		 1 if there are no waiters.
+ *	Return: false if there are waiters (wait_for_completion() in progress)
+ *		 true if there are no waiters.
  *
  */
 bool completion_done(struct completion *x)
-- 
2.1.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ