1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

tree-wide: use !IN_SET(..) for a != b && a != c && …

The included cocci was used to generate the changes.

Thanks to @flo-wer for pointing this case out.
This commit is contained in:
Andreas Rammhold 2017-09-29 09:58:22 +02:00
parent 3742095b27
commit ec2ce0c5d7
No known key found for this signature in database
GPG Key ID: E432E410B5E48C86
24 changed files with 185 additions and 60 deletions

147
coccinelle/not_in_set.cocci Normal file
View File

@ -0,0 +1,147 @@
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9 && e != n10 && e != n11 && e != n12 && e != n13 && e != n14 && e != n15 && e != n16 && e != n17 && e != n18 && e != n19 && e != n20
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9 && e != n10 && e != n11 && e != n12 && e != n13 && e != n14 && e != n15 && e != n16 && e != n17 && e != n18 && e != n19
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9 && e != n10 && e != n11 && e != n12 && e != n13 && e != n14 && e != n15 && e != n16 && e != n17 && e != n18
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9 && e != n10 && e != n11 && e != n12 && e != n13 && e != n14 && e != n15 && e != n16 && e != n17
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9 && e != n10 && e != n11 && e != n12 && e != n13 && e != n14 && e != n15 && e != n16
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9 && e != n10 && e != n11 && e != n12 && e != n13 && e != n14 && e != n15
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9 && e != n10 && e != n11 && e != n12 && e != n13 && e != n14
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9 && e != n10 && e != n11 && e != n12 && e != n13
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9 && e != n10 && e != n11 && e != n12
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9 && e != n10 && e != n11
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9 && e != n10
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8, n9;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8 && e != n9
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7, n8;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7 && e != n8
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7, n8)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6, n7;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6 && e != n7
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6, n7)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5, n6;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5 && e != n6
+ !IN_SET(e, n0, n1, n2, n3, n4, n5, n6)
@@
expression e;
identifier n0, n1, n2, n3, n4, n5;
statement s;
@@
- e != n0 && e != n1 && e != n2 && e != n3 && e != n4 && e != n5
+ !IN_SET(e, n0, n1, n2, n3, n4, n5)
@@
expression e;
identifier n1, n2, n3, n4, n5;
statement s;
@@
- e != n1 && e != n2 && e != n3 && e != n4 && e != n5
+ !IN_SET(e, n1, n2, n3, n4, n5)
@@
expression e;
identifier n1, n2, n3, n4;
statement s;
@@
- e != n1 && e != n2 && e != n3 && e != n4
+ !IN_SET(e, n1, n2, n3, n4)
@@
expression e;
identifier n1, n2, n3, n4;
statement s;
@@
- e != n1 && e != n2 && e != n3 && e != n4
+ !IN_SET(e, n1, n2, n3, n4)
@@
expression e;
identifier n1, n2, n3;
statement s;
@@
- e != n1 && e != n2 && e != n3
+ !IN_SET(e, n1, n2, n3)
@@
expression e;
identifier n, p;
statement s;
@@
- e != n && e != p
+ !IN_SET(e, n, p)

View File

@ -202,7 +202,7 @@ int rm_rf(const char *path, RemoveFlags flags) {
fd = open(path, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME);
if (fd < 0) {
if (errno != ENOTDIR && errno != ELOOP)
if (!IN_SET(errno, ENOTDIR, ELOOP))
return -errno;
if (!(flags & REMOVE_PHYSICAL)) {

View File

@ -268,7 +268,7 @@ int socket_address_verify(const SocketAddress *a) {
if (a->sockaddr.in.sin_port == 0)
return -EINVAL;
if (a->type != SOCK_STREAM && a->type != SOCK_DGRAM)
if (!IN_SET(a->type, SOCK_STREAM, SOCK_DGRAM))
return -EINVAL;
return 0;
@ -280,7 +280,7 @@ int socket_address_verify(const SocketAddress *a) {
if (a->sockaddr.in6.sin6_port == 0)
return -EINVAL;
if (a->type != SOCK_STREAM && a->type != SOCK_DGRAM)
if (!IN_SET(a->type, SOCK_STREAM, SOCK_DGRAM))
return -EINVAL;
return 0;
@ -304,7 +304,7 @@ int socket_address_verify(const SocketAddress *a) {
}
}
if (a->type != SOCK_STREAM && a->type != SOCK_DGRAM && a->type != SOCK_SEQPACKET)
if (!IN_SET(a->type, SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET))
return -EINVAL;
return 0;
@ -314,7 +314,7 @@ int socket_address_verify(const SocketAddress *a) {
if (a->size != sizeof(struct sockaddr_nl))
return -EINVAL;
if (a->type != SOCK_RAW && a->type != SOCK_DGRAM)
if (!IN_SET(a->type, SOCK_RAW, SOCK_DGRAM))
return -EINVAL;
return 0;
@ -323,7 +323,7 @@ int socket_address_verify(const SocketAddress *a) {
if (a->size != sizeof(struct sockaddr_vm))
return -EINVAL;
if (a->type != SOCK_STREAM && a->type != SOCK_DGRAM)
if (!IN_SET(a->type, SOCK_STREAM, SOCK_DGRAM))
return -EINVAL;
return 0;

View File

@ -48,7 +48,7 @@ int get_audit_fd(void) {
audit_fd = audit_open();
if (audit_fd < 0) {
if (errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
if (!IN_SET(errno, EAFNOSUPPORT, EPROTONOSUPPORT))
log_error_errno(errno, "Failed to connect to audit log: %m");
audit_fd = errno ? -errno : -EINVAL;

View File

@ -251,8 +251,7 @@ static void automount_set_state(Automount *a, AutomountState state) {
if (state != AUTOMOUNT_RUNNING)
automount_stop_expire(a);
if (state != AUTOMOUNT_WAITING &&
state != AUTOMOUNT_RUNNING)
if (!IN_SET(state, AUTOMOUNT_WAITING, AUTOMOUNT_RUNNING))
unmount_autofs(a);
if (state != old_state)

View File

@ -174,8 +174,7 @@ static int killall(int sig, Set *pids, bool send_sighup) {
pid_t pid;
int r;
if (d->d_type != DT_DIR &&
d->d_type != DT_UNKNOWN)
if (!IN_SET(d->d_type, DT_DIR, DT_UNKNOWN))
continue;
if (parse_pid(d->d_name, &pid) < 0)

View File

@ -2513,9 +2513,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
if (detect_container() > 0)
return;
if (u->type != UNIT_SERVICE &&
u->type != UNIT_MOUNT &&
u->type != UNIT_SWAP)
if (!IN_SET(u->type, UNIT_SERVICE, UNIT_MOUNT, UNIT_SWAP))
return;
/* We set SOCK_NONBLOCK here so that we rather drop the

View File

@ -669,8 +669,7 @@ static int path_dispatch_io(sd_event_source *source, int fd, uint32_t revents, v
p = PATH(s->unit);
if (p->state != PATH_WAITING &&
p->state != PATH_RUNNING)
if (!IN_SET(p->state, PATH_WAITING, PATH_RUNNING))
return 0;
/* log_debug("inotify wakeup on %s.", u->id); */

View File

@ -2055,7 +2055,7 @@ static void socket_enter_signal(Socket *s, SocketState state, SocketResult f) {
r = unit_kill_context(
UNIT(s),
&s->kill_context,
(state != SOCKET_STOP_PRE_SIGTERM && state != SOCKET_FINAL_SIGTERM) ?
!IN_SET(state, SOCKET_STOP_PRE_SIGTERM, SOCKET_FINAL_SIGTERM) ?
KILL_KILL : KILL_TERMINATE,
-1,
s->control_pid,
@ -2448,9 +2448,7 @@ static int socket_start(Unit *u) {
/* If the service is already active we cannot start the
* socket */
if (service->state != SERVICE_DEAD &&
service->state != SERVICE_FAILED &&
service->state != SERVICE_AUTO_RESTART) {
if (!IN_SET(service->state, SERVICE_DEAD, SERVICE_FAILED, SERVICE_AUTO_RESTART)) {
log_unit_error(u, "Socket service %s already active, refusing.", UNIT(service)->id);
return -EBUSY;
}

View File

@ -778,8 +778,7 @@ int unit_merge(Unit *u, Unit *other) {
if (!unit_type_may_alias(u->type)) /* Merging only applies to unit names that support aliases */
return -EEXIST;
if (other->load_state != UNIT_STUB &&
other->load_state != UNIT_NOT_FOUND)
if (!IN_SET(other->load_state, UNIT_STUB, UNIT_NOT_FOUND))
return -EEXIST;
if (other->job)
@ -2221,7 +2220,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
if (u->job->state == JOB_RUNNING) {
if (ns == UNIT_ACTIVE)
job_finish_and_invalidate(u->job, reload_success ? JOB_DONE : JOB_FAILED, true, false);
else if (ns != UNIT_ACTIVATING && ns != UNIT_RELOADING) {
else if (!IN_SET(ns, UNIT_ACTIVATING, UNIT_RELOADING)) {
unexpected = true;
if (UNIT_IS_INACTIVE_OR_FAILED(ns))

View File

@ -135,7 +135,7 @@ int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCo
c->xz.avail_out = sizeof(buffer);
lzr = lzma_code(&c->xz, LZMA_RUN);
if (lzr != LZMA_OK && lzr != LZMA_STREAM_END)
if (!IN_SET(lzr, LZMA_OK, LZMA_STREAM_END))
return -EIO;
r = callback(buffer, sizeof(buffer) - c->xz.avail_out, userdata);
@ -156,7 +156,7 @@ int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCo
c->gzip.avail_out = sizeof(buffer);
r = inflate(&c->gzip, Z_NO_FLUSH);
if (r != Z_OK && r != Z_STREAM_END)
if (!IN_SET(r, Z_OK, Z_STREAM_END))
return -EIO;
r = callback(buffer, sizeof(buffer) - c->gzip.avail_out, userdata);
@ -177,7 +177,7 @@ int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCo
c->bzip2.avail_out = sizeof(buffer);
r = BZ2_bzDecompress(&c->bzip2);
if (r != BZ_OK && r != BZ_STREAM_END)
if (!IN_SET(r, BZ_OK, BZ_STREAM_END))
return -EIO;
r = callback(buffer, sizeof(buffer) - c->bzip2.avail_out, userdata);
@ -399,7 +399,7 @@ int import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size
c->xz.avail_out = *buffer_allocated - *buffer_size;
lzr = lzma_code(&c->xz, LZMA_FINISH);
if (lzr != LZMA_OK && lzr != LZMA_STREAM_END)
if (!IN_SET(lzr, LZMA_OK, LZMA_STREAM_END))
return -EIO;
*buffer_size += (*buffer_allocated - *buffer_size) - c->xz.avail_out;
@ -420,7 +420,7 @@ int import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size
c->gzip.avail_out = *buffer_allocated - *buffer_size;
r = deflate(&c->gzip, Z_FINISH);
if (r != Z_OK && r != Z_STREAM_END)
if (!IN_SET(r, Z_OK, Z_STREAM_END))
return -EIO;
*buffer_size += (*buffer_allocated - *buffer_size) - c->gzip.avail_out;
@ -440,7 +440,7 @@ int import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size
c->bzip2.avail_out = *buffer_allocated - *buffer_size;
r = BZ2_bzCompress(&c->bzip2, BZ_FINISH);
if (r != BZ_FINISH_OK && r != BZ_STREAM_END)
if (!IN_SET(r, BZ_FINISH_OK, BZ_STREAM_END))
return -EIO;
*buffer_size += (*buffer_allocated - *buffer_size) - c->bzip2.avail_out;

View File

@ -417,7 +417,7 @@ static int transfer_start(Transfer *t) {
}
}
if (pipefd[1] != STDOUT_FILENO && pipefd[1] != STDERR_FILENO)
if (!IN_SET(pipefd[1], STDOUT_FILENO, STDERR_FILENO))
pipefd[1] = safe_close(pipefd[1]);
if (t->stdin_fd >= 0) {

View File

@ -1650,8 +1650,7 @@ uint64_t journal_file_entry_array_n_items(Object *o) {
uint64_t journal_file_hash_table_n_items(Object *o) {
assert(o);
if (o->object.type != OBJECT_DATA_HASH_TABLE &&
o->object.type != OBJECT_FIELD_HASH_TABLE)
if (!IN_SET(o->object.type, OBJECT_DATA_HASH_TABLE, OBJECT_FIELD_HASH_TABLE))
return 0;
return (le64toh(o->object.size) - offsetof(Object, hash_table.items)) / sizeof(HashItem);
@ -3241,8 +3240,7 @@ int journal_file_open(
assert(ret);
assert(fd >= 0 || fname);
if ((flags & O_ACCMODE) != O_RDONLY &&
(flags & O_ACCMODE) != O_RDWR)
if (!IN_SET((flags & O_ACCMODE), O_RDONLY, O_RDWR))
return -EINVAL;
if (fname) {

View File

@ -302,7 +302,7 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
if (errno == ENOENT)
return 0;
if (errno != EMSGSIZE && errno != ENOBUFS)
if (!IN_SET(errno, EMSGSIZE, ENOBUFS))
return -errno;
/* Message doesn't fit... Let's dump the data in a memfd or

View File

@ -455,9 +455,7 @@ int sd_dhcp_client_set_mtu(sd_dhcp_client *client, uint32_t mtu) {
int sd_dhcp_client_get_lease(sd_dhcp_client *client, sd_dhcp_lease **ret) {
assert_return(client, -EINVAL);
if (client->state != DHCP_STATE_BOUND &&
client->state != DHCP_STATE_RENEWING &&
client->state != DHCP_STATE_REBINDING)
if (!IN_SET(client->state, DHCP_STATE_BOUND, DHCP_STATE_RENEWING, DHCP_STATE_REBINDING))
return -EADDRNOTAVAIL;
if (ret)

View File

@ -354,7 +354,7 @@ static int user_mkdir_runtime_path(User *u) {
r = mount("tmpfs", u->runtime_path, "tmpfs", MS_NODEV|MS_NOSUID, t);
if (r < 0) {
if (errno != EPERM && errno != EACCES) {
if (!IN_SET(errno, EPERM, EACCES)) {
r = log_error_errno(errno, "Failed to mount per-user tmpfs directory %s: %m", u->runtime_path);
goto fail;
}

View File

@ -749,16 +749,7 @@ int config_parse_tunnel(const char *unit,
return 0;
}
if (netdev->kind != NETDEV_KIND_IPIP &&
netdev->kind != NETDEV_KIND_SIT &&
netdev->kind != NETDEV_KIND_GRE &&
netdev->kind != NETDEV_KIND_GRETAP &&
netdev->kind != NETDEV_KIND_IP6GRE &&
netdev->kind != NETDEV_KIND_IP6GRETAP &&
netdev->kind != NETDEV_KIND_VTI &&
netdev->kind != NETDEV_KIND_VTI6 &&
netdev->kind != NETDEV_KIND_IP6TNL
) {
if (!IN_SET(netdev->kind, NETDEV_KIND_IPIP, NETDEV_KIND_SIT, NETDEV_KIND_GRE, NETDEV_KIND_GRETAP, NETDEV_KIND_IP6GRE, NETDEV_KIND_IP6GRETAP, NETDEV_KIND_VTI, NETDEV_KIND_VTI6, NETDEV_KIND_IP6TNL)) {
log_syntax(unit, LOG_ERR, filename, line, 0,
"NetDev is not a tunnel, ignoring assignment: %s", rvalue);
return 0;

View File

@ -337,7 +337,7 @@ enum nss_status _nss_myhostname_gethostbyname3_r(
if (af == AF_UNSPEC)
af = AF_INET;
if (af != AF_INET && af != AF_INET6) {
if (!IN_SET(af, AF_INET, AF_INET6)) {
*errnop = EAFNOSUPPORT;
*h_errnop = NO_DATA;
return NSS_STATUS_UNAVAIL;

View File

@ -221,7 +221,7 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
ss = writev(fd, iov, 2);
if (ss < 0) {
if (errno != EINTR && errno != EAGAIN)
if (!IN_SET(errno, EINTR, EAGAIN))
return dns_stream_complete(s, errno);
} else
s->n_written += ss;
@ -243,7 +243,7 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
ss = read(fd, (uint8_t*) &s->read_size + s->n_read, sizeof(s->read_size) - s->n_read);
if (ss < 0) {
if (errno != EINTR && errno != EAGAIN)
if (!IN_SET(errno, EINTR, EAGAIN))
return dns_stream_complete(s, errno);
} else if (ss == 0)
return dns_stream_complete(s, ECONNRESET);
@ -293,7 +293,7 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
(uint8_t*) DNS_PACKET_DATA(s->read_packet) + s->n_read - sizeof(s->read_size),
sizeof(s->read_size) + be16toh(s->read_size) - s->n_read);
if (ss < 0) {
if (errno != EINTR && errno != EAGAIN)
if (!IN_SET(errno, EINTR, EAGAIN))
return dns_stream_complete(s, errno);
} else if (ss == 0)
return dns_stream_complete(s, ECONNRESET);

View File

@ -167,7 +167,7 @@ static int connection_shovel(
} else if (z == 0 || errno == EPIPE || errno == ECONNRESET) {
*from_source = sd_event_source_unref(*from_source);
*from = safe_close(*from);
} else if (errno != EAGAIN && errno != EINTR)
} else if (!IN_SET(errno, EAGAIN, EINTR))
return log_error_errno(errno, "Failed to splice: %m");
}
@ -179,7 +179,7 @@ static int connection_shovel(
} else if (z == 0 || errno == EPIPE || errno == ECONNRESET) {
*to_source = sd_event_source_unref(*to_source);
*to = safe_close(*to);
} else if (errno != EAGAIN && errno != EINTR)
} else if (!IN_SET(errno, EAGAIN, EINTR))
return log_error_errno(errno, "Failed to splice: %m");
}
} while (shoveled);

View File

@ -192,8 +192,7 @@ static void test_proc(void) {
pid_t pid;
uid_t uid = UID_INVALID;
if (de->d_type != DT_DIR &&
de->d_type != DT_UNKNOWN)
if (!IN_SET(de->d_type, DT_DIR, DT_UNKNOWN))
continue;
r = parse_pid(de->d_name, &pid);

View File

@ -54,7 +54,7 @@ static void check(Manager *m, Unit *unit, int status_expected, int code_expected
printf("%s\n", unit->id);
exec_context_dump(&service->exec_context, stdout, "\t");
ts = now(CLOCK_MONOTONIC);
while (service->state != SERVICE_DEAD && service->state != SERVICE_FAILED) {
while (!IN_SET(service->state, SERVICE_DEAD, SERVICE_FAILED)) {
int r;
usec_t n;

View File

@ -54,7 +54,7 @@ void probe_smart_media(int mtd_fd, mtd_info_t* info)
block_size = info->erasesize;
size_in_megs = info->size / (1024 * 1024);
if (sector_size != SM_SECTOR_SIZE && sector_size != SM_SMALL_PAGE)
if (!IN_SET(sector_size, SM_SECTOR_SIZE, SM_SMALL_PAGE))
goto exit;
switch(size_in_megs) {

View File

@ -411,7 +411,7 @@ static struct udev_device *handle_scsi_default(struct udev_device *parent, char
if (dent->d_name[0] == '.')
continue;
if (dent->d_type != DT_DIR && dent->d_type != DT_LNK)
if (!IN_SET(dent->d_type, DT_DIR, DT_LNK))
continue;
if (!startswith(dent->d_name, "host"))
continue;