From: Alejandro Colomar Date: Thu, 27 Jun 2024 15:19:36 +0000 (+0200) Subject: lib/: Use multi-line macro definitions X-Git-Tag: 4.17.0-rc1~175 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5111e5ed1b7b8063b64abc6b37c530aba38c187d;p=thirdparty%2Fshadow.git lib/: Use multi-line macro definitions This reduces the complexity of those nested parentheses. Signed-off-by: Alejandro Colomar --- diff --git a/lib/alloc/calloc.h b/lib/alloc/calloc.h index 5c093434a..fb170e6f2 100644 --- a/lib/alloc/calloc.h +++ b/lib/alloc/calloc.h @@ -11,7 +11,10 @@ #include -#define CALLOC(n, type) ((type *) calloc(n, sizeof(type))) +#define CALLOC(n, type) \ +( \ + (type *) calloc(n, sizeof(type)) \ +) #endif // include guard diff --git a/lib/alloc/malloc.h b/lib/alloc/malloc.h index 5badeebb2..214782551 100644 --- a/lib/alloc/malloc.h +++ b/lib/alloc/malloc.h @@ -13,7 +13,10 @@ #include "attr.h" -#define MALLOC(n, type) ((type *) mallocarray(n, sizeof(type))) +#define MALLOC(n, type) \ +( \ + (type *) mallocarray(n, sizeof(type)) \ +) ATTR_MALLOC(free) diff --git a/lib/alloc/x/xcalloc.h b/lib/alloc/x/xcalloc.h index b78d104f5..04cf1ad43 100644 --- a/lib/alloc/x/xcalloc.h +++ b/lib/alloc/x/xcalloc.h @@ -14,7 +14,10 @@ #include "attr.h" -#define XCALLOC(n, type) ((type *) xcalloc(n, sizeof(type))) +#define XCALLOC(n, type) \ +( \ + (type *) xcalloc(n, sizeof(type)) \ +) ATTR_MALLOC(free) diff --git a/lib/alloc/x/xmalloc.h b/lib/alloc/x/xmalloc.h index 967e18bce..02fde6629 100644 --- a/lib/alloc/x/xmalloc.h +++ b/lib/alloc/x/xmalloc.h @@ -14,7 +14,10 @@ #include "attr.h" -#define XMALLOC(n, type) ((type *) xmallocarray(n, sizeof(type))) +#define XMALLOC(n, type) \ +( \ + (type *) xmallocarray(n, sizeof(type)) \ +) ATTR_MALLOC(free) diff --git a/lib/must_be.h b/lib/must_be.h index a7365cba5..6ae6c7998 100644 --- a/lib/must_be.h +++ b/lib/must_be.h @@ -90,10 +90,28 @@ */ -#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