diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-06-28 18:37:34 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-07-02 12:46:16 +0200 |
commit | 64903d18dfd0344d5af3c0f8006b2e220de90091 (patch) | |
tree | f6ed4047b5d324adb513115fc9315ce25aaec5af /src/udev | |
parent | Merge pull request #23827 from yuwata/sd-event-process-buffered-inotify-data (diff) | |
download | systemd-64903d18dfd0344d5af3c0f8006b2e220de90091.tar.xz systemd-64903d18dfd0344d5af3c0f8006b2e220de90091.zip |
basic/list: drop LIST_IS_EMPTY
This was a trivial wrapper that didn't provide any added value. With more
complicated structures like strvs, hashmaps, sets, and arrays, it is possible
to have an empty container. But in case of a list, the list is empty only when
the head is missing.
Also, we generally want the positive condition, so we replace many
if (!LIST_IS_EMPTY(x)) with just if (x).
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/udev-rules.c | 2 | ||||
-rw-r--r-- | src/udev/udevd.c | 7 |
2 files changed, 4 insertions, 5 deletions
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 |