[Mesa-dev] [PATCH] util: use cannonical form of ARRAY_SIZE
Eric Engestrom
eric.engestrom at imgtec.com
Tue Aug 1 09:54:07 UTC 2017
On Monday, 2017-07-31 19:45:48 +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
>
> Namely sizeof(foo)/sizeof((foo)[])
>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
> ---
> src/util/macros.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/util/macros.h b/src/util/macros.h
> index a66f1bfed07..a9a52a1a478 100644
> --- a/src/util/macros.h
> +++ b/src/util/macros.h
> @@ -30,7 +30,7 @@
>
> /* Compute the size of an array */
> #ifndef ARRAY_SIZE
> -# define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
> +# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> #endif
>
> /* For compatibility with Clang's __has_builtin() */
> --
> 2.13.3
>
More information about the mesa-dev
mailing list