summaryrefslogtreecommitdiff
path: root/src/systemctl/systemctl.c
diff options
context:
space:
mode:
authorSimon Peeters <peeters.simon@gmail.com>2014-01-04 02:35:27 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-01-05 09:16:15 -0500
commite3e45d4f82daa5cd85ba40dde9127df900096c0c (patch)
tree307e427adfd64298ff3f21f6c6fd97aca1e17d42 /src/systemctl/systemctl.c
parentbf85c24daaf63f72562bbe4c627ca8b963dfb964 (diff)
strv: multiple cleanups
- turn strv_merge into strv_extend_strv. appending strv b to the end of strv a instead of creating a new strv - strv_append: remove in favor of strv_extend and strv_push. - strv_remove: write slightly more elegant - strv_remove_prefix: remove unused function - strv_overlap: use strv_contains - strv_printf: STRV_FOREACH handles NULL correctly
Diffstat (limited to 'src/systemctl/systemctl.c')
-rw-r--r--src/systemctl/systemctl.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 01a4489f4d..dd95df14e7 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1327,7 +1327,7 @@ static int list_dependencies_one(
char ***units,
unsigned int branches) {
- _cleanup_strv_free_ char **deps = NULL, **u;
+ _cleanup_strv_free_ char **deps = NULL;
char **c;
int r = 0;
@@ -1335,8 +1335,8 @@ static int list_dependencies_one(
assert(name);
assert(units);
- u = strv_append(*units, name);
- if (!u)
+ r = strv_extend(units, name);
+ if (r < 0)
return log_oom();
r = list_dependencies_get_dependencies(bus, name, &deps);
@@ -1348,7 +1348,7 @@ static int list_dependencies_one(
STRV_FOREACH(c, deps) {
int state;
- if (strv_contains(u, *c)) {
+ if (strv_contains(*units, *c)) {
if (!arg_plain) {
r = list_dependencies_print("...", level + 1, (branches << 1) | (c[1] == NULL ? 0 : 1), 1);
if (r < 0)
@@ -1368,17 +1368,14 @@ static int list_dependencies_one(
return r;
if (arg_all || unit_name_to_type(*c) == UNIT_TARGET) {
- r = list_dependencies_one(bus, *c, level + 1, &u, (branches << 1) | (c[1] == NULL ? 0 : 1));
+ r = list_dependencies_one(bus, *c, level + 1, units, (branches << 1) | (c[1] == NULL ? 0 : 1));
if (r < 0)
return r;
}
}
- if (arg_plain) {
- strv_free(*units);
- *units = u;
- u = NULL;
- }
+ if (!arg_plain)
+ strv_remove(*units, name);
return 0;
}