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:
+1
-1
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user