mirror of
https://github.com/systemd/systemd.git
synced 2026-08-04 23:20:32 +00:00
systemctl: drop unneeded condition
This commit is contained in:
@@ -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;
|
||||
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;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user