Re: [PATCH 2/3] compiler.h: Introduce __must_be_char_array()
From: David Laight
Date: Thu Feb 06 2025 - 14:57:09 EST
On Thu, 6 Feb 2025 10:11:29 -0800
Kees Cook <kees@xxxxxxxxxx> wrote:
> In preparation for adding stricter type checking to the str/mem*()
> helpers, provide a way to check that a variable is a character array
> via __must_be_char_array().
>
...
> +#define __is_char_array(a) (__is_array(a) && sizeof((a)[0]) == 1)
> +#define __must_be_char_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_char_array(a), \
> + "must be byte array")
If you are only checking the size, perhaps __is_byte_array() would
be a better name.
(You've even used 'byte' in the error message.)
David