tree-wide: add new SIGNAL_VALID() macro-like function that validates signal numbers

And port all code over to use it.
This commit is contained in:
Lennart Poettering
2016-04-12 13:43:32 +02:00
parent 4c310c073a
commit 6eb7c172b5
9 changed files with 20 additions and 13 deletions
+1 -1
View File
@@ -255,7 +255,7 @@ int signal_from_string(const char *s) {
}
if (safe_atou(s, &u) >= 0) {
signo = (int) u + offset;
if (signo > 0 && signo < _NSIG)
if (SIGNAL_VALID(signo))
return signo;
}
return -EINVAL;
+4
View File
@@ -50,3 +50,7 @@ static inline void block_signals_reset(sigset_t *ss) {
assert_se(sigprocmask_many(SIG_BLOCK, &t, __VA_ARGS__, -1) >= 0); \
t; \
})
static inline bool SIGNAL_VALID(int signo) {
return signo > 0 && signo < _NSIG;
}