diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-09-20 20:38:27 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-09-22 10:16:05 +0200 |
commit | c8b62cf60064b8bcbb95db6e97d1ca3931eba341 (patch) | |
tree | 07570e10ebf60a777ea0c33da2f3ccf95b7703c9 /src/systemctl | |
parent | networkctl: use "-" for empty fields (diff) | |
download | systemd-c8b62cf60064b8bcbb95db6e97d1ca3931eba341.tar.xz systemd-c8b62cf60064b8bcbb95db6e97d1ca3931eba341.zip |
shared/format-table: use enum instead of Table.empty_string
All users were setting this to some static string (usually "-"), so let's
simplify things by not doing strdup, but instead limiting callers to a fixed
set of values. In preparation for the next commit, the function is renamed from
"empty" to "replacement", because it'll be used for more than empty fields. I
didn't do the whole string-table setup, because it's all used internally in one
file and this way we can immediately assert if an invalid value is passed in.
Some callers were (void)ing the error, others were ignoring it, and others
propagating. It's nicer to remove the boilerplate.
Diffstat (limited to 'src/systemctl')
-rw-r--r-- | src/systemctl/systemctl-list-jobs.c | 2 | ||||
-rw-r--r-- | src/systemctl/systemctl-list-machines.c | 2 | ||||
-rw-r--r-- | src/systemctl/systemctl-list-unit-files.c | 2 | ||||
-rw-r--r-- | src/systemctl/systemctl-list-units.c | 8 |
4 files changed, 7 insertions, 7 deletions
diff --git a/src/systemctl/systemctl-list-jobs.c b/src/systemctl/systemctl-list-jobs.c index f9eba23683..a752173e4e 100644 --- a/src/systemctl/systemctl-list-jobs.c +++ b/src/systemctl/systemctl-list-jobs.c @@ -83,7 +83,7 @@ static int output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned n if (arg_full) table_set_width(table, 0); - (void) table_set_empty_string(table, "-"); + table_set_ersatz_string(table, TABLE_ERSATZ_DASH); for (const struct job_info *j = jobs; j < jobs + n; j++) { if (streq(j->state, "running")) diff --git a/src/systemctl/systemctl-list-machines.c b/src/systemctl/systemctl-list-machines.c index 121d5ab9ce..4407d2598a 100644 --- a/src/systemctl/systemctl-list-machines.c +++ b/src/systemctl/systemctl-list-machines.c @@ -171,7 +171,7 @@ static int output_machines_list(struct machine_info *machine_infos, unsigned n) if (arg_full) table_set_width(table, 0); - (void) table_set_empty_string(table, "-"); + table_set_ersatz_string(table, TABLE_ERSATZ_DASH); for (struct machine_info *m = machine_infos; m < machine_infos + n; m++) { _cleanup_free_ char *mname = NULL; diff --git a/src/systemctl/systemctl-list-unit-files.c b/src/systemctl/systemctl-list-unit-files.c index fa7a789b28..96b22041f4 100644 --- a/src/systemctl/systemctl-list-unit-files.c +++ b/src/systemctl/systemctl-list-unit-files.c @@ -62,7 +62,7 @@ static int output_unit_file_list(const UnitFileList *units, unsigned c) { if (arg_full) table_set_width(table, 0); - (void) table_set_empty_string(table, "-"); + table_set_ersatz_string(table, TABLE_ERSATZ_DASH); for (const UnitFileList *u = units; u < units + c; u++) { const char *on_underline = NULL, *on_unit_color = NULL, *id; diff --git a/src/systemctl/systemctl-list-units.c b/src/systemctl/systemctl-list-units.c index 5a1311f5ea..6bfaf97236 100644 --- a/src/systemctl/systemctl-list-units.c +++ b/src/systemctl/systemctl-list-units.c @@ -120,7 +120,7 @@ static int output_units_list(const UnitInfo *unit_infos, size_t c) { if (arg_full) table_set_width(table, 0); - (void) table_set_empty_string(table, "-"); + table_set_ersatz_string(table, TABLE_ERSATZ_DASH); for (const UnitInfo *u = unit_infos; unit_infos && (size_t) (u - unit_infos) < c; u++) { _cleanup_free_ char *j = NULL; @@ -381,7 +381,7 @@ static int output_sockets_list(struct socket_info *socket_infos, size_t cs) { if (arg_full) table_set_width(table, 0); - (void) table_set_empty_string(table, "-"); + table_set_ersatz_string(table, TABLE_ERSATZ_DASH); for (struct socket_info *s = socket_infos; s < socket_infos + cs; s++) { _cleanup_free_ char *j = NULL; @@ -612,7 +612,7 @@ static int output_timers_list(struct timer_info *timer_infos, size_t n) { if (arg_full) table_set_width(table, 0); - (void) table_set_empty_string(table, "-"); + table_set_ersatz_string(table, TABLE_ERSATZ_DASH); for (struct timer_info *t = timer_infos; t < timer_infos + n; t++) { _cleanup_free_ char *j = NULL, *activates = NULL; @@ -844,7 +844,7 @@ static int output_automounts_list(struct automount_info *infos, size_t n_infos) if (arg_full) table_set_width(table, 0); - (void) table_set_empty_string(table, "-"); + table_set_ersatz_string(table, TABLE_ERSATZ_DASH); for (struct automount_info *info = infos; info < infos + n_infos; info++) { _cleanup_free_ char *j = NULL; |