From d5379b350fb63e42e604361c21ad9832b4c791b9 Mon Sep 17 00:00:00 2001 From: Daniel Martin Date: Fri, 27 Oct 2017 16:11:56 +0200 Subject: Use ARRAY_SIZE all over the tree Roundhouse kick replacing the various (sizeof(foo)/sizeof(foo[0])) with the ARRAY_SIZE macro from dix.h when possible. A semantic patch for coccinelle has been used first. Additionally, a few macros have been inlined as they had only one or two users. Signed-off-by: Daniel Martin Reviewed-by: Adam Jackson --- os/auth.c | 3 +-- os/oscolor.c | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'os') diff --git a/os/auth.c b/os/auth.c index 9d87c1f39..da8b70985 100644 --- a/os/auth.c +++ b/os/auth.c @@ -90,8 +90,7 @@ static struct protocol protocols[] = { #endif }; -#define NUM_AUTHORIZATION (sizeof (protocols) /\ - sizeof (struct protocol)) +#define NUM_AUTHORIZATION ARRAY_SIZE(protocols) /* * Initialize all classes of authorization by reading the diff --git a/os/oscolor.c b/os/oscolor.c index 017aab1f2..af83c6ada 100644 --- a/os/oscolor.c +++ b/os/oscolor.c @@ -49,6 +49,7 @@ SOFTWARE. #endif #include +#include "dix.h" #include "os.h" typedef struct _builtinColor { @@ -1628,8 +1629,6 @@ static const BuiltinColor BuiltinColors[] = { {154, 205, 50, 7602}, /* YellowGreen */ }; -#define NUM_BUILTIN_COLORS (sizeof (BuiltinColors) / sizeof (BuiltinColors[0])) - Bool OsLookupColor(int screen, char *name, @@ -1642,7 +1641,7 @@ OsLookupColor(int screen, int r; low = 0; - high = NUM_BUILTIN_COLORS - 1; + high = ARRAY_SIZE(BuiltinColors) - 1; while (high >= low) { mid = (low + high) / 2; c = &BuiltinColors[mid]; -- cgit v1.2.3