(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); \
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 { \
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) {
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;
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);
}
}
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)
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;
}
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. */
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);
if (!d)
return;
- if (!LIST_IS_EMPTY(d->event_sources))
+ if (d->event_sources)
return;
inotify_data = d->inotify_data;
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;
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 (;;) {
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);
}
"%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();
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]);
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)
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);
.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");
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