]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/format-table: use empty_string instead of hardcoding "-" for invalid values 24768/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Sep 2022 18:39:16 +0000 (20:39 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 22 Sep 2022 08:16:30 +0000 (10:16 +0200)
As requested in https://github.com/systemd/systemd/pull/24708#discussion_r973607866.

src/shared/format-table.c

index 3572eb2a3233ea9a63bb9f67c2d88607dea0176a..b62445faa6a0c7e2ce77fcf1e4e8a41cc754d5b2 100644 (file)
@@ -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)