From 29ca430865376ce82142a7b65fad91a25b208679 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 20 Sep 2022 20:39:16 +0200 Subject: [PATCH] shared/format-table: use empty_string instead of hardcoding "-" for invalid values As requested in https://github.com/systemd/systemd/pull/24708#discussion_r973607866. --- src/shared/format-table.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/shared/format-table.c b/src/shared/format-table.c index 3572eb2a323..b62445faa6a 100644 --- a/src/shared/format-table.c +++ b/src/shared/format-table.c @@ -1510,7 +1510,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas return NULL; if (!format_bytes(p, FORMAT_BYTES_MAX, d->size)) - return "-"; + return table_ersatz_string(t); d->formatted = TAKE_PTR(p); break; @@ -1525,7 +1525,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas return NULL; if (!format_bytes_full(p, FORMAT_BYTES_MAX, d->size, 0)) - return "-"; + return table_ersatz_string(t); n = strlen(p); strscpy(p + n, FORMAT_BYTES_MAX + 2 - n, "bps"); @@ -1726,7 +1726,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas char *p; if (!uid_is_valid(d->uid)) - return "-"; + return table_ersatz_string(t); p = new(char, DECIMAL_STR_WIDTH(d->uid) + 1); if (!p) @@ -1741,7 +1741,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas char *p; if (!gid_is_valid(d->gid)) - return "-"; + return table_ersatz_string(t); p = new(char, DECIMAL_STR_WIDTH(d->gid) + 1); if (!p) @@ -1756,7 +1756,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas char *p; if (!pid_is_valid(d->pid)) - return "-"; + return table_ersatz_string(t); p = new(char, DECIMAL_STR_WIDTH(d->pid) + 1); if (!p) @@ -1773,7 +1773,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas suffix = signal_to_string(d->int_val); if (!suffix) - return "-"; + return table_ersatz_string(t); p = strjoin("SIG", suffix); if (!p) @@ -1787,7 +1787,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas char *p; if (d->mode == MODE_INVALID) - return "-"; + return table_ersatz_string(t); p = new(char, 4 + 1); if (!p) -- 2.47.3