diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-04-08 11:27:28 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-04-12 13:43:32 +0200 |
commit | 6eb7c172b58d81a5f6c3998ce304a7324fc65050 (patch) | |
tree | a720b0f860bc65bfc09cbbafe869b2974d7d0c16 /src/basic | |
parent | 4c310c073aec5a31a7e626ea8ceb86d3a28291aa (diff) |
tree-wide: add new SIGNAL_VALID() macro-like function that validates signal numbers
And port all code over to use it.
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/signal-util.c | 2 | ||||
-rw-r--r-- | src/basic/signal-util.h | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c index e3047b209b..280b5c3251 100644 --- a/src/basic/signal-util.c +++ b/src/basic/signal-util.c @@ -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; diff --git a/src/basic/signal-util.h b/src/basic/signal-util.h index a7322ff26a..dfd6eb564d 100644 --- a/src/basic/signal-util.h +++ b/src/basic/signal-util.h @@ -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; +} |