From: David Tardon Date: Mon, 25 Jul 2022 07:28:31 +0000 (+0200) Subject: systemctl: drop unneeded condition X-Git-Tag: v252-rc1~580^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=25facd0384bc6aefe7accabb50796c765a26c160;p=thirdparty%2Fsystemd.git systemctl: drop unneeded condition --- diff --git a/src/systemctl/systemctl-list-units.c b/src/systemctl/systemctl-list-units.c index a6596ddd0ea..96bc4d47eab 100644 --- a/src/systemctl/systemctl-list-units.c +++ b/src/systemctl/systemctl-list-units.c @@ -352,6 +352,8 @@ static int output_sockets_list(struct socket_info *socket_infos, size_t cs) { _cleanup_(table_unrefp) Table *table = NULL; int r; + assert(socket_infos || cs == 0); + table = table_new("listen", "type", "unit", "activates"); if (!table) return log_oom(); @@ -369,38 +371,36 @@ static int output_sockets_list(struct socket_info *socket_infos, size_t cs) { (void) table_set_empty_string(table, "-"); - if (cs > 0) { - for (struct socket_info *s = socket_infos; s < socket_infos + cs; s++) { - _cleanup_free_ char *j = NULL; - const char *path; - - if (s->machine) { - j = strjoin(s->machine, ":", s->path); - if (!j) - return log_oom(); - path = j; - } else - path = s->path; - - r = table_add_many(table, - TABLE_STRING, path, - TABLE_STRING, s->type, - TABLE_STRING, s->id); - if (r < 0) - return table_log_add_error(r); - - if (strv_isempty(s->triggered)) - r = table_add_cell(table, NULL, TABLE_EMPTY, NULL); - else if (strv_length(s->triggered) == 1) - r = table_add_cell(table, NULL, TABLE_STRING, s->triggered[0]); - else - /* This should never happen, currently our socket units can only trigger a - * single unit. But let's handle this anyway, who knows what the future - * brings? */ - r = table_add_cell(table, NULL, TABLE_STRV, s->triggered); - if (r < 0) - return table_log_add_error(r); - } + for (struct socket_info *s = socket_infos; s < socket_infos + cs; s++) { + _cleanup_free_ char *j = NULL; + const char *path; + + if (s->machine) { + j = strjoin(s->machine, ":", s->path); + if (!j) + return log_oom(); + path = j; + } else + path = s->path; + + r = table_add_many(table, + TABLE_STRING, path, + TABLE_STRING, s->type, + TABLE_STRING, s->id); + if (r < 0) + return table_log_add_error(r); + + if (strv_isempty(s->triggered)) + r = table_add_cell(table, NULL, TABLE_EMPTY, NULL); + else if (strv_length(s->triggered) == 1) + r = table_add_cell(table, NULL, TABLE_STRING, s->triggered[0]); + else + /* This should never happen, currently our socket units can only trigger a + * single unit. But let's handle this anyway, who knows what the future + * brings? */ + r = table_add_cell(table, NULL, TABLE_STRV, s->triggered); + if (r < 0) + return table_log_add_error(r); } r = output_table(table);