summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coccinelle/macros.h2
-rw-r--r--src/basic/list.h3
-rw-r--r--src/core/cgroup.c2
-rw-r--r--src/core/dbus-cgroup.c2
-rw-r--r--src/core/dbus-execute.c8
-rw-r--r--src/core/dbus-util.c2
-rw-r--r--src/core/load-fragment.c8
-rw-r--r--src/core/unit.c2
-rw-r--r--src/libsystemd/sd-event/sd-event.c8
-rw-r--r--src/resolve/resolved-conf.c2
-rw-r--r--src/resolve/resolved-dnssd.c2
-rw-r--r--src/test/test-list.c2
-rw-r--r--src/udev/udev-rules.c2
-rw-r--r--src/udev/udevd.c7
14 files changed, 23 insertions, 29 deletions
diff --git a/coccinelle/macros.h b/coccinelle/macros.h
index 6a0a64bb05..f44b3f2d26 100644
--- a/coccinelle/macros.h
+++ b/coccinelle/macros.h
@@ -189,8 +189,6 @@
(i) != (p); \
(i) = (i)->name##_next ? (i)->name##_next : (head))
-#define LIST_IS_EMPTY(head) \
- (!(head))
#define LIST_JOIN(name,a,b) \
do { \
assert(b); \
diff --git a/src/basic/list.h b/src/basic/list.h
index 58e83a6cb2..ca30039690 100644
--- a/src/basic/list.h
+++ b/src/basic/list.h
@@ -170,9 +170,6 @@
i != (p); \
i = i->name##_next ? i->name##_next : (head))
-#define LIST_IS_EMPTY(head) \
- (!(head))
-
/* Join two lists tail to head: a->b, c->d to a->b->c->d and de-initialise second list */
#define LIST_JOIN(name,a,b) \
do { \
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 25707fce64..0fce812b40 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -1689,7 +1689,7 @@ static bool unit_get_needs_bpf_foreign_program(Unit *u) {
if (!c)
return false;
- return !LIST_IS_EMPTY(c->bpf_foreign_programs);
+ return !!c->bpf_foreign_programs;
}
static bool unit_get_needs_socket_bind(Unit *u) {
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index 607370d7bf..7e95f0e390 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -737,7 +737,7 @@ static int bus_cgroup_set_transient_property(
unit_write_setting(u, flags, name, buf);
- if (!LIST_IS_EMPTY(c->bpf_foreign_programs)) {
+ if (c->bpf_foreign_programs) {
r = bpf_foreign_supported();
if (r < 0)
return r;
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 1a9e5da635..8de092ee4e 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -1698,16 +1698,16 @@ int bus_exec_context_set_transient_property(
return r;
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- if (LIST_IS_EMPTY(options)) {
- c->root_image_options = mount_options_free_all(c->root_image_options);
- unit_write_settingf(u, flags, name, "%s=", name);
- } else {
+ if (options) {
LIST_JOIN(mount_options, c->root_image_options, options);
unit_write_settingf(
u, flags|UNIT_ESCAPE_SPECIFIERS, name,
"%s=%s",
name,
format_str);
+ } else {
+ c->root_image_options = mount_options_free_all(c->root_image_options);
+ unit_write_settingf(u, flags, name, "%s=", name);
}
}
diff --git a/src/core/dbus-util.c b/src/core/dbus-util.c
index 32a2ec0ff9..264a4f55b6 100644
--- a/src/core/dbus-util.c
+++ b/src/core/dbus-util.c
@@ -216,7 +216,7 @@ int bus_read_mount_options(
if (r < 0)
return r;
- if (!LIST_IS_EMPTY(options)) {
+ if (options) {
if (ret_format_str) {
char *final = strjoin(*ret_format_str, !isempty(*ret_format_str) ? separator : "", format_str);
if (!final)
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 3ff6eae8fc..313f667cd7 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -1691,11 +1691,11 @@ int config_parse_root_image_options(
LIST_APPEND(mount_options, options, TAKE_PTR(o));
}
- /* empty spaces/separators only */
- if (LIST_IS_EMPTY(options))
- c->root_image_options = mount_options_free_all(c->root_image_options);
- else
+ if (options)
LIST_JOIN(mount_options, c->root_image_options, options);
+ else
+ /* empty spaces/separators only */
+ c->root_image_options = mount_options_free_all(c->root_image_options);
return 0;
}
diff --git a/src/core/unit.c b/src/core/unit.c
index 180dccc2b2..40fc79995a 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -4138,7 +4138,7 @@ int unit_patch_contexts(Unit *u) {
cc->device_policy == CGROUP_DEVICE_POLICY_AUTO)
cc->device_policy = CGROUP_DEVICE_POLICY_CLOSED;
- if ((ec->root_image || !LIST_IS_EMPTY(ec->mount_images)) &&
+ if ((ec->root_image || ec->mount_images) &&
(cc->device_policy != CGROUP_DEVICE_POLICY_AUTO || cc->device_allow)) {
/* When RootImage= or MountImages= is specified, the following devices are touched. */
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index a37147d1d5..5833a83346 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -1799,7 +1799,7 @@ static void event_free_inode_data(
if (!d)
return;
- assert(LIST_IS_EMPTY(d->event_sources));
+ assert(!d->event_sources);
if (d->fd >= 0) {
LIST_REMOVE(to_close, e->inode_data_to_close, d);
@@ -1862,7 +1862,7 @@ static void event_gc_inode_data(
if (!d)
return;
- if (!LIST_IS_EMPTY(d->event_sources))
+ if (d->event_sources)
return;
inotify_data = d->inotify_data;
@@ -3874,7 +3874,7 @@ _public_ int sd_event_prepare(sd_event *e) {
event_close_inode_data_fds(e);
- if (event_next_pending(e) || e->need_process_child || !LIST_IS_EMPTY(e->inotify_data_buffered))
+ if (event_next_pending(e) || e->need_process_child || e->inotify_data_buffered)
goto pending;
e->state = SD_EVENT_ARMED;
@@ -3954,7 +3954,7 @@ static int process_epoll(sd_event *e, usec_t timeout, int64_t threshold, int64_t
n_event_max = MALLOC_ELEMENTSOF(e->event_queue);
/* If we still have inotify data buffered, then query the other fds, but don't wait on it */
- if (!LIST_IS_EMPTY(e->inotify_data_buffered))
+ if (e->inotify_data_buffered)
timeout = 0;
for (;;) {
diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c
index a25dffae63..babd19b925 100644
--- a/src/resolve/resolved-conf.c
+++ b/src/resolve/resolved-conf.c
@@ -394,7 +394,7 @@ int config_parse_dnssd_txt(
last = i;
}
- if (!LIST_IS_EMPTY(txt_data->txt)) {
+ if (txt_data->txt) {
LIST_PREPEND(items, s->txt_data_items, txt_data);
TAKE_PTR(txt_data);
}
diff --git a/src/resolve/resolved-dnssd.c b/src/resolve/resolved-dnssd.c
index 9c2594c1ba..169c942308 100644
--- a/src/resolve/resolved-dnssd.c
+++ b/src/resolve/resolved-dnssd.c
@@ -107,7 +107,7 @@ static int dnssd_service_load(Manager *manager, const char *filename) {
"%s doesn't define service type",
service->name);
- if (LIST_IS_EMPTY(service->txt_data_items)) {
+ if (!service->txt_data_items) {
txt_data = new0(DnssdTxtData, 1);
if (!txt_data)
return log_oom();
diff --git a/src/test/test-list.c b/src/test/test-list.c
index 78bbad8e4e..dc7ecb7572 100644
--- a/src/test/test-list.c
+++ b/src/test/test-list.c
@@ -240,7 +240,7 @@ int main(int argc, const char *argv[]) {
LIST_JOIN(item, head, head2);
assert_se(head2 == NULL);
- assert_se(!LIST_IS_EMPTY(head));
+ assert_se(head);
for (i = 0; i < ELEMENTSOF(items); i++)
LIST_REMOVE(item, head, &items[i]);
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index f95b751b75..9bbf797acd 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1063,7 +1063,7 @@ static void sort_tokens(UdevRuleLine *rule_line) {
head_old = TAKE_PTR(rule_line->tokens);
rule_line->current_token = NULL;
- while (!LIST_IS_EMPTY(head_old)) {
+ while (head_old) {
UdevRuleToken *min_token = NULL;
LIST_FOREACH(tokens, t, head_old)
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 1994b6b2d5..d3e949dae4 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1008,8 +1008,7 @@ static int event_queue_start(Manager *manager) {
assert(manager);
- if (LIST_IS_EMPTY(manager->events) ||
- manager->exit || manager->stop_exec_queue)
+ if (!manager->events || manager->exit || manager->stop_exec_queue)
return 0;
assert_se(sd_event_now(manager->event, CLOCK_MONOTONIC, &usec) >= 0);
@@ -1166,7 +1165,7 @@ static int event_queue_insert(Manager *manager, sd_device *dev) {
.state = EVENT_QUEUED,
};
- if (LIST_IS_EMPTY(manager->events)) {
+ if (!manager->events) {
r = touch("/run/udev/queue");
if (r < 0)
log_warning_errno(r, "Failed to touch /run/udev/queue, ignoring: %m");
@@ -1611,7 +1610,7 @@ static int on_post(sd_event_source *s, void *userdata) {
assert(manager);
- if (!LIST_IS_EMPTY(manager->events)) {
+ if (manager->events) {
/* Try to process pending events if idle workers exist. Why is this necessary?
* When a worker finished an event and became idle, even if there was a pending event,
* the corresponding device might have been locked and the processing of the event