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.
This commit is contained in:
+1
-1
@@ -171,7 +171,7 @@ void barrier_set_role(Barrier *b, unsigned int role) {
|
||||
int fd;
|
||||
|
||||
assert(b);
|
||||
assert(role == BARRIER_PARENT || role == BARRIER_CHILD);
|
||||
assert(IN_SET(role, BARRIER_PARENT, BARRIER_CHILD));
|
||||
/* make sure this is only called once */
|
||||
assert(b->pipe[0] >= 0 && b->pipe[1] >= 0);
|
||||
|
||||
|
||||
+4
-3
@@ -70,11 +70,11 @@ bool barrier_sync_next(Barrier *b);
|
||||
bool barrier_sync(Barrier *b);
|
||||
|
||||
static inline bool barrier_i_aborted(Barrier *b) {
|
||||
return b->barriers == BARRIER_I_ABORTED || b->barriers == BARRIER_WE_ABORTED;
|
||||
return IN_SET(b->barriers, BARRIER_I_ABORTED, BARRIER_WE_ABORTED);
|
||||
}
|
||||
|
||||
static inline bool barrier_they_aborted(Barrier *b) {
|
||||
return b->barriers == BARRIER_THEY_ABORTED || b->barriers == BARRIER_WE_ABORTED;
|
||||
return IN_SET(b->barriers, BARRIER_THEY_ABORTED, BARRIER_WE_ABORTED);
|
||||
}
|
||||
|
||||
static inline bool barrier_we_aborted(Barrier *b) {
|
||||
@@ -82,7 +82,8 @@ static inline bool barrier_we_aborted(Barrier *b) {
|
||||
}
|
||||
|
||||
static inline bool barrier_is_aborted(Barrier *b) {
|
||||
return b->barriers == BARRIER_I_ABORTED || b->barriers == BARRIER_THEY_ABORTED || b->barriers == BARRIER_WE_ABORTED;
|
||||
return IN_SET(b->barriers, BARRIER_I_ABORTED, BARRIER_THEY_ABORTED,
|
||||
BARRIER_WE_ABORTED);
|
||||
}
|
||||
|
||||
static inline bool barrier_place_and_sync(Barrier *b) {
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ int in_addr_prefix_from_string(const char *p, int family, union in_addr_union *r
|
||||
int in_addr_prefix_from_string_auto(const char *p, int *ret_family, union in_addr_union *ret_prefix, unsigned char *ret_prefixlen);
|
||||
|
||||
static inline size_t FAMILY_ADDRESS_SIZE(int family) {
|
||||
assert(family == AF_INET || family == AF_INET6);
|
||||
assert(IN_SET(family, AF_INET, AF_INET6));
|
||||
return family == AF_INET6 ? 16 : 4;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,9 +154,7 @@ static int get_line(JournalImporter *imp, char **line, size_t *size) {
|
||||
static int fill_fixed_size(JournalImporter *imp, void **data, size_t size) {
|
||||
|
||||
assert(imp);
|
||||
assert(imp->state == IMPORTER_STATE_DATA_START ||
|
||||
imp->state == IMPORTER_STATE_DATA ||
|
||||
imp->state == IMPORTER_STATE_DATA_FINISH);
|
||||
assert(IN_SET(imp->state, IMPORTER_STATE_DATA_START, IMPORTER_STATE_DATA, IMPORTER_STATE_DATA_FINISH));
|
||||
assert(size <= DATA_SIZE_MAX);
|
||||
assert(imp->offset <= imp->filled);
|
||||
assert(imp->filled <= imp->size);
|
||||
|
||||
@@ -688,8 +688,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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
@@ -1081,7 +1080,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;
|
||||
|
||||
@@ -476,7 +476,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;
|
||||
|
||||
+1
-1
@@ -378,7 +378,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;
|
||||
|
||||
Reference in New Issue
Block a user