From 445bd57e397ac77bc0f6ca0165bbc70397341c45 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 26 May 2020 09:13:39 +0200 Subject: [PATCH] busctl: drop unneeded param --- src/busctl/busctl.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 4879b466e30..8e000ee1196 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -424,29 +424,15 @@ static void print_subtree(const char *prefix, const char *path, char **l) { } } -static void print_tree(const char *prefix, char **l) { - - prefix = strempty(prefix); - - if (arg_list) { - char **i; - - STRV_FOREACH(i, l) - printf("%s%s\n", prefix, *i); - return; - } - - if (strv_isempty(l)) { +static void print_tree(char **l) { + if (arg_list) + strv_print(l); + else if (strv_isempty(l)) printf("No objects discovered.\n"); - return; - } - - if (streq(l[0], "/") && !l[1]) { + else if (streq(l[0], "/") && !l[1]) printf("Only root object discovered.\n"); - return; - } - - print_subtree(prefix, "/", l); + else + print_subtree("", "/", l); } static int on_path(const char *path, void *userdata) { @@ -490,7 +476,7 @@ static int find_nodes(sd_bus *bus, const char *service, const char *path, Set *p return parse_xml_introspect(path, xml, &ops, paths); } -static int tree_one(sd_bus *bus, const char *service, const char *prefix) { +static int tree_one(sd_bus *bus, const char *service) { _cleanup_set_free_ Set *paths = NULL, *done = NULL, *failed = NULL; _cleanup_free_ char **l = NULL; int r; @@ -536,7 +522,7 @@ static int tree_one(sd_bus *bus, const char *service, const char *prefix) { return log_oom(); strv_sort(l); - print_tree(prefix, l); + print_tree(l); fflush(stdout); @@ -585,7 +571,7 @@ static int tree(int argc, char **argv, void *userdata) { printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal()); - q = tree_one(bus, *i, NULL); + q = tree_one(bus, *i); if (q < 0 && r >= 0) r = q; @@ -603,7 +589,7 @@ static int tree(int argc, char **argv, void *userdata) { printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal()); } - q = tree_one(bus, *i, NULL); + q = tree_one(bus, *i); if (q < 0 && r >= 0) r = q; } -- 2.47.3