tree-wide: propagate the error we got from strv_extend_xyz() to the caller

It's a bit sloppy to return -ENOMEM rather than the actual error we
already returned in the first place (even though it's always going to be
ENOMEM)
This commit is contained in:
Lennart Poettering
2024-01-16 23:22:43 +01:00
parent 4212636763
commit 010cd1dc58
6 changed files with 20 additions and 15 deletions

View File

@@ -1517,7 +1517,7 @@ int get_timezones(char ***ret) {
/* Always include UTC */
r = strv_extend(&zones, "UTC");
if (r < 0)
return -ENOMEM;
return r;
strv_sort(zones);
strv_uniq(zones);

View File

@@ -1949,7 +1949,7 @@ int bus_exec_context_set_transient_property(
r = strv_extend_strv(&c->supplementary_groups, l, true);
if (r < 0)
return -ENOMEM;
return r;
joined = strv_join(c->supplementary_groups, " ");
if (!joined)
@@ -3174,7 +3174,7 @@ int bus_exec_context_set_transient_property(
r = strv_extend_strv(dirs, l, true);
if (r < 0)
return -ENOMEM;
return r;
unit_write_settingf(u, flags, name, "%s=%s", name, joined);
}
@@ -3201,7 +3201,7 @@ int bus_exec_context_set_transient_property(
_cleanup_free_ char *joined = NULL;
r = strv_extend_strv(&c->exec_search_path, l, true);
if (r < 0)
return -ENOMEM;
return r;
joined = strv_join(c->exec_search_path, ":");
if (!joined)
return log_oom();

View File

@@ -494,8 +494,9 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
(void) exec_shared_runtime_deserialize_one(m, val, fds);
else if ((val = startswith(l, "subscribed="))) {
if (strv_extend(&m->deserialized_subscribed, val) < 0)
return -ENOMEM;
r = strv_extend(&m->deserialized_subscribed, val);
if (r < 0)
return r;
} else if ((val = startswith(l, "varlink-server-socket-address="))) {
if (!m->varlink_server && MANAGER_IS_SYSTEM(m)) {
r = manager_varlink_init(m);

View File

@@ -3098,7 +3098,7 @@ int service_deserialize_exec_command(
case STATE_EXEC_COMMAND_ARGS:
r = strv_extend(&argv, arg);
if (r < 0)
return -ENOMEM;
return r;
break;
default:
assert_not_reached();

View File

@@ -8,6 +8,7 @@
static int denylist_modules(const char *p, char ***denylist) {
_cleanup_strv_free_ char **k = NULL;
int r;
assert(p);
assert(denylist);
@@ -16,8 +17,9 @@ static int denylist_modules(const char *p, char ***denylist) {
if (!k)
return -ENOMEM;
if (strv_extend_strv(denylist, k, true) < 0)
return -ENOMEM;
r = strv_extend_strv(denylist, k, /* filter_duplicates= */ true);
if (r < 0)
return r;
return 0;
}

View File

@@ -347,6 +347,7 @@ static int putgrent_with_members(
FILE *group) {
char **a;
int r;
assert(c);
assert(gr);
@@ -365,15 +366,15 @@ static int putgrent_with_members(
if (strv_contains(l, *i))
continue;
if (strv_extend(&l, *i) < 0)
return -ENOMEM;
r = strv_extend(&l, *i);
if (r < 0)
return r;
added = true;
}
if (added) {
struct group t;
int r;
strv_uniq(l);
strv_sort(l);
@@ -396,6 +397,7 @@ static int putsgent_with_members(
FILE *gshadow) {
char **a;
int r;
assert(sg);
assert(gshadow);
@@ -413,15 +415,15 @@ static int putsgent_with_members(
if (strv_contains(l, *i))
continue;
if (strv_extend(&l, *i) < 0)
return -ENOMEM;
r = strv_extend(&l, *i);
if (r < 0)
return r;
added = true;
}
if (added) {
struct sgrp t;
int r;
strv_uniq(l);
strv_sort(l);