]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/format-table: rework loop
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 7 Apr 2021 14:55:27 +0000 (16:55 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 7 Apr 2021 15:05:35 +0000 (17:05 +0200)
Not a big difference, but I think it's a bit nicer this way.

src/shared/format-table.c

index 6bbc8bd509e1dfc9b0562b5b3336bcfbaa331e3b..8d816f4ec6c5879e5934ea594c1b58d7f777200e 100644 (file)
@@ -783,19 +783,17 @@ int table_update(Table *t, TableCell *cell, TableDataType type, const void *data
 }
 
 int table_add_many_internal(Table *t, TableDataType first_type, ...) {
-        TableDataType type;
-        va_list ap;
         TableCell *last_cell = NULL;
+        va_list ap;
         int r;
 
         assert(t);
         assert(first_type >= 0);
         assert(first_type < _TABLE_DATA_TYPE_MAX);
 
-        type = first_type;
-
         va_start(ap, first_type);
-        for (;;) {
+
+        for (TableDataType type = first_type;; type = va_arg(ap, TableDataType)) {
                 const void *data;
                 union {
                         uint64_t size;
@@ -1048,8 +1046,6 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
                         va_end(ap);
                         return r;
                 }
-
-                type = va_arg(ap, TableDataType);
         }
 }