]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: Use non-empty compound literals
authorAlejandro Colomar <alx@kernel.org>
Tue, 30 Dec 2025 15:17:55 +0000 (16:17 +0100)
committerSerge Hallyn <serge@hallyn.com>
Tue, 30 Dec 2025 16:07:45 +0000 (10:07 -0600)
While the empty one is more correct, {0} will also work, and will
likely silence diagnostics in old compiler versions.

Empty compound literals are only supported in GCC since commit
gcc.git 14cfa01755a6 (2022-08-25; "c: Support C2x empty initializer braces")

Reported-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/atoi/a2i.h
lib/search/cmp/cmp.h
lib/sizeof.h
lib/typetraits.h

index 6d67496fe49cf63590153e51e851bf1152dd58bb..e7ece423adeb7a5f785857bd76d5aa1d1697b6b0 100644 (file)
@@ -26,7 +26,7 @@
                                                                      \
        int  status;                                                  \
                                                                      \
-       *n_ = _Generic((T){},                                         \
+       *n_ = _Generic((T){0},                                        \
                short:              strtoi_,                          \
                int:                strtoi_,                          \
                long:               strtoi_,                          \
index 3e81e052efc12740eaf9626b0530b74aac5bc8d8..d9ed1ab096cad8620ec7b29b898245d7fd7dd872 100644 (file)
@@ -11,7 +11,7 @@
 
 #define CMP(T)                                                        \
 (                                                                     \
-       _Generic((T){},                                               \
+       _Generic((T){0},                                              \
                int:            cmp_int,                              \
                long:           cmp_long,                             \
                unsigned int:   cmp_uint,                             \
index 0b82ac9776b45ec9bba7d14ee3d8b325ff6ce985..1fc38873dd9ecd063a14478a26407a0a9bba956f 100644 (file)
@@ -15,7 +15,7 @@
 #include <sys/types.h>
 
 
-#define typeas(T)            typeof((T){})
+#define typeas(T)            typeof((T){0})
 
 #define ssizeof(x)           ({(ssize_t){sizeof(x)};})
 #define memberof(T, member)  ((T){}.member)
index 051edfc66f14d83cc9573a1ddb32ab26ffb3a1ed..fb3d970d97432c3a01d848138054c599629130c5 100644 (file)
 #define QChar_of(s)  typeof                                           \
 (                                                                     \
        _Generic(s,                                                   \
-               const char *:  (const char){},                        \
-               const void *:  (const char){},                        \
-               char *:        (char){},                              \
-               void *:        (char){                              \
+               const char *:  (const char){0},                       \
+               const void *:  (const char){0},                       \
+               char *:        (char){0},                             \
+               void *:        (char){0}                              \
        )                                                             \
 )