From a4488a7509a96d8b9f0d7793517a217c70ac0361 Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Fri, 29 Sep 2017 00:37:23 +0200 Subject: tree-wide: use IN_SET where possible In addition to the changes from #6933 this handles cases that could be matched with the included cocci file. --- src/basic/hashmap.c | 2 +- src/basic/process-util.c | 3 +-- src/basic/signal-util.c | 2 +- src/basic/socket-util.c | 5 ++--- src/basic/terminal-util.c | 2 +- src/basic/util.c | 2 +- 6 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src/basic') diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c index 86d648df0..51190b381 100644 --- a/src/basic/hashmap.c +++ b/src/basic/hashmap.c @@ -927,7 +927,7 @@ static bool hashmap_put_robin_hood(HashmapBase *h, unsigned idx, for (distance = 0; ; distance++) { raw_dib = dibs[idx]; - if (raw_dib == DIB_RAW_FREE || raw_dib == DIB_RAW_REHASH) { + if (IN_SET(raw_dib, DIB_RAW_FREE, DIB_RAW_REHASH)) { if (raw_dib == DIB_RAW_REHASH) bucket_move_entry(h, swap, idx, IDX_TMP); diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 2b31cbb2b..22d6f5059 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -692,8 +692,7 @@ int wait_for_terminate_and_warn(const char *name, pid_t pid, bool check_exit_cod log_debug("%s succeeded.", name); return status.si_status; - } else if (status.si_code == CLD_KILLED || - status.si_code == CLD_DUMPED) { + } else if (IN_SET(status.si_code, CLD_KILLED, CLD_DUMPED)) { log_warning("%s terminated by signal %s.", name, signal_to_string(status.si_status)); return -EPROTO; diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c index 8e83bfcf0..043c71466 100644 --- a/src/basic/signal-util.c +++ b/src/basic/signal-util.c @@ -38,7 +38,7 @@ int reset_all_signal_handlers(void) { for (sig = 1; sig < _NSIG; sig++) { /* These two cannot be caught... */ - if (sig == SIGKILL || sig == SIGSTOP) + if (IN_SET(sig, SIGKILL, SIGSTOP)) continue; /* On Linux the first two RT signals are reserved by diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 5487d1b05..c32b8d3e1 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -364,8 +364,7 @@ bool socket_address_can_accept(const SocketAddress *a) { assert(a); return - a->type == SOCK_STREAM || - a->type == SOCK_SEQPACKET; + IN_SET(a->type, SOCK_STREAM, SOCK_SEQPACKET); } bool socket_address_equal(const SocketAddress *a, const SocketAddress *b) { @@ -1085,7 +1084,7 @@ ssize_t next_datagram_size_fd(int fd) { l = recv(fd, NULL, 0, MSG_PEEK|MSG_TRUNC); if (l < 0) { - if (errno == EOPNOTSUPP || errno == EFAULT) + if (IN_SET(errno, EOPNOTSUPP, EFAULT)) goto fallback; return -errno; diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index d580c6dac..b83e778b2 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -479,7 +479,7 @@ int acquire_terminal( l = read(notify, &buffer, sizeof(buffer)); if (l < 0) { - if (errno == EINTR || errno == EAGAIN) + if (IN_SET(errno, EINTR, EAGAIN)) continue; r = -errno; diff --git a/src/basic/util.c b/src/basic/util.c index 463f6fd12..3dfe1ff65 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -383,7 +383,7 @@ int on_ac_power(void) { device = openat(dirfd(d), de->d_name, O_DIRECTORY|O_RDONLY|O_CLOEXEC|O_NOCTTY); if (device < 0) { - if (errno == ENOENT || errno == ENOTDIR) + if (IN_SET(errno, ENOENT, ENOTDIR)) continue; return -errno; -- cgit v1.2.3