From: Alejandro Colomar Date: Wed, 21 May 2025 11:58:05 +0000 (+0200) Subject: lib/sizeof.h: Define SIZEOF_ARRAY() in terms of countof() X-Git-Tag: 4.18.0-rc1~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c5d8fcb4cdd96547563d382fece1e7ea6dff19de;p=thirdparty%2Fshadow.git lib/sizeof.h: Define SIZEOF_ARRAY() in terms of countof() This will allow us to eventually get rid of must_be_array(), once we make sure countof() is safe. Signed-off-by: Alejandro Colomar --- diff --git a/lib/sizeof.h b/lib/sizeof.h index fc1a2dd3e..af7cf4b9b 100644 --- a/lib/sizeof.h +++ b/lib/sizeof.h @@ -20,12 +20,12 @@ #define ssizeof(x) ((ssize_t) sizeof(x)) #define memberof(T, member) ((T){}.member) #define WIDTHOF(x) (sizeof(x) * CHAR_BIT) -#define SIZEOF_ARRAY(a) (sizeof(a) + must_be_array(a)) #if !defined(countof) -# define countof(a) (SIZEOF_ARRAY((a)) / sizeof((a)[0])) +# define countof(a) (sizeof(a) / sizeof((a)[0]) + must_be_array(a)) #endif +#define SIZEOF_ARRAY(a) (countof(a) * sizeof((a)[0])) #define STRLEN(s) (countof("" s "") - 1)