]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: Use multi-line macro definitions
authorAlejandro Colomar <alx@kernel.org>
Thu, 27 Jun 2024 15:19:36 +0000 (17:19 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 2 Jul 2024 02:40:11 +0000 (21:40 -0500)
This reduces the complexity of those nested parentheses.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/alloc/calloc.h
lib/alloc/malloc.h
lib/alloc/x/xcalloc.h
lib/alloc/x/xmalloc.h
lib/must_be.h

index 5c093434a624c0020f6f913aa162b960bfbdad82..fb170e6f2430d48aa6ed87128dcda70ecd81e97b 100644 (file)
 #include <stdlib.h>
 
 
-#define CALLOC(n, type)   ((type *) calloc(n, sizeof(type)))
+#define CALLOC(n, type)                                                       \
+(                                                                             \
+       (type *) calloc(n, sizeof(type))                                      \
+)
 
 
 #endif  // include guard
index 5badeebb28abb92626521d6c07a616235812242e..21478255116da3a486a521afe24ed182da7efea2 100644 (file)
 #include "attr.h"
 
 
-#define MALLOC(n, type)   ((type *) mallocarray(n, sizeof(type)))
+#define MALLOC(n, type)                                                       \
+(                                                                             \
+       (type *) mallocarray(n, sizeof(type))                                 \
+)
 
 
 ATTR_MALLOC(free)
index b78d104f525497ff618e853b0b460e75371bc021..04cf1ad438f803690290147cf28674ca857f09c4 100644 (file)
 #include "attr.h"
 
 
-#define XCALLOC(n, type)  ((type *) xcalloc(n, sizeof(type)))
+#define XCALLOC(n, type)                                                      \
+(                                                                             \
+       (type *) xcalloc(n, sizeof(type))                                     \
+)
 
 
 ATTR_MALLOC(free)
index 967e18bcef7df3fc01cd6adaa865791f37e82aae..02fde662975758c51033e277c4ea4768e689d322 100644 (file)
 #include "attr.h"
 
 
-#define XMALLOC(n, type)  ((type *) xmallocarray(n, sizeof(type)))
+#define XMALLOC(n, type)                                                      \
+(                                                                             \
+       (type *) xmallocarray(n, sizeof(type))                                \
+)
 
 
 ATTR_MALLOC(free)
index a7365cba53f36ab692147410fd35cf07fd5189a5..6ae6c7998f2e962b6e0081c1997691ba11d50b37 100644 (file)
  */
 
 
-#define is_same_type(a, b)    __builtin_types_compatible_p(a, b)
-#define is_same_typeof(a, b)  is_same_type(typeof(a), typeof(b))
-#define is_array(a)           (!is_same_typeof((a), &(a)[0]))
-#define must_be_array(a)      must_be(is_array(a))
+#define is_same_type(a, b)                                                    \
+(                                                                             \
+       __builtin_types_compatible_p(a, b)                                    \
+)
+
+
+#define is_same_typeof(a, b)                                                  \
+(                                                                             \
+       is_same_type(typeof(a), typeof(b))                                    \
+)
+
+
+#define is_array(a)                                                           \
+(                                                                             \
+       !is_same_typeof(a, &(a)[0])                                           \
+)
+
+
+#define must_be_array(a)                                                      \
+(                                                                             \
+       must_be(is_array(a))                                                  \
+)
 
 
 #endif  // include guard