]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
string-table: make DUMP_STRING_TABLE() returns 0
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 12 Dec 2024 02:31:16 +0000 (11:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 12 Dec 2024 06:21:16 +0000 (15:21 +0900)
Then, we can use it as
===
  return DUMP_STRING_TABLE(...);
===

src/basic/string-table.h

index 639443d02b38b404e8cc742c5e7316d81fb2de7f..83891eeb738910f02ab1aae56532822a831cd373 100644 (file)
@@ -101,7 +101,7 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
         _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING_FALLBACK(name,type,max,static)
 
 #define DUMP_STRING_TABLE(name,type,max)                                \
-        do {                                                            \
+        ({                                                              \
                 flockfile(stdout);                                      \
                 for (type _k = 0; _k < (max); _k++) {                   \
                         const char *_t;                                 \
@@ -112,4 +112,5 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
                         fputc_unlocked('\n', stdout);                   \
                 }                                                       \
                 funlockfile(stdout);                                    \
-        } while (false)
+                0;                                                      \
+        })