summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorDaniel Martin <consume.noise@gmail.com>2017-10-27 16:11:56 +0200
committerAdam Jackson <ajax@redhat.com>2017-10-30 13:45:20 -0400
commitd5379b350fb63e42e604361c21ad9832b4c791b9 (patch)
tree9ff0602258e2d4afb74561614810fb8a8e0e1860 /os
parent15a32ee5d1fffa171bb05af9a0e5b472e4af1488 (diff)
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 <consume.noise@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'os')
-rw-r--r--os/auth.c3
-rw-r--r--os/oscolor.c5
2 files changed, 3 insertions, 5 deletions
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 <X11/keysym.h>
+#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];