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).
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2022-07-02 12:46:16 +02:00
parent a4d60b3e1c
commit 64903d18df
14 changed files with 23 additions and 29 deletions
+1 -1
View File
@@ -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)
+3 -4
View File
@@ -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