]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
format-table: don't hit assert if column got less width than it asked for
authorLennart Poettering <lennart@poettering.net>
Tue, 9 Feb 2021 14:02:21 +0000 (15:02 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 9 Feb 2021 14:05:25 +0000 (15:05 +0100)
If one field in a specific column has a maximum size limit, other fields
in the same column might affected by it and get less than they asked
for. Let's make sure we can handle this, and don't assert on this
because surprisingly we got less than what we asked for.

src/shared/format-table.c

index 8b9c81664df2baadecf70bc61be119903bbf76dc..e3d8a051a22824e836f36524e6c77ffce3720c77 100644 (file)
@@ -1993,8 +1993,7 @@ int table_print(Table *t, FILE *f) {
                                 if (width[j] < minimum_width[j])
                                         width[j] = minimum_width[j];
 
-                                assert(width[j] >= requested_width[j]);
-                                delta = width[j] - requested_width[j];
+                                delta = LESS_BY(width[j], requested_width[j]);
 
                                 /* Subtract what we just added from the rest */
                                 if (extra > delta)