[PATCH v2 10/17] signal: make has_pending_signals() return bool

From: Christian Brauner
Date: Fri Jun 01 2018 - 09:23:18 EST


has_pending_signals() already behaves like a boolean function. Let's
actually declare it as such too.

Signed-off-by: Christian Brauner <christian@xxxxxxxxxx>
---
v1->v2:
* unchanged
v0->v1:
* patch added
---
kernel/signal.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index e48675bd3be8..faf38b46d124 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -110,30 +110,33 @@ static bool sig_ignored(struct task_struct *t, int sig, bool force)
* Re-calculate pending state from the set of locally pending
* signals, globally pending signals, and blocked signals.
*/
-static inline int has_pending_signals(sigset_t *signal, sigset_t *blocked)
+static inline bool has_pending_signals(sigset_t *signal, sigset_t *blocked)
{
unsigned long ready;
long i;

switch (_NSIG_WORDS) {
default:
- for (i = _NSIG_WORDS, ready = 0; --i >= 0 ;)
- ready |= signal->sig[i] &~ blocked->sig[i];
+ for (i = _NSIG_WORDS, ready = 0; --i >= 0;)
+ ready |= signal->sig[i] & ~blocked->sig[i];
break;

- case 4: ready = signal->sig[3] &~ blocked->sig[3];
- ready |= signal->sig[2] &~ blocked->sig[2];
- ready |= signal->sig[1] &~ blocked->sig[1];
- ready |= signal->sig[0] &~ blocked->sig[0];
+ case 4:
+ ready = signal->sig[3] & ~blocked->sig[3];
+ ready |= signal->sig[2] & ~blocked->sig[2];
+ ready |= signal->sig[1] & ~blocked->sig[1];
+ ready |= signal->sig[0] & ~blocked->sig[0];
break;

- case 2: ready = signal->sig[1] &~ blocked->sig[1];
- ready |= signal->sig[0] &~ blocked->sig[0];
+ case 2:
+ ready = signal->sig[1] & ~blocked->sig[1];
+ ready |= signal->sig[0] & ~blocked->sig[0];
break;

- case 1: ready = signal->sig[0] &~ blocked->sig[0];
+ case 1:
+ ready = signal->sig[0] & ~blocked->sig[0];
}
- return ready != 0;
+ return ready != 0;
}

#define PENDING(p,b) has_pending_signals(&(p)->signal, (b))
--
2.17.0