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>
This commit is contained in:
Daniel Martin
2017-10-27 16:11:56 +02:00
committed by Adam Jackson
parent 15a32ee5d1
commit d5379b350f
44 changed files with 66 additions and 105 deletions

View File

@@ -581,8 +581,6 @@ static const RESTYPE CursorRestypes[] = {
RT_WINDOW, RT_PASSIVEGRAB, RT_CURSOR
};
#define NUM_CURSOR_RESTYPES (sizeof (CursorRestypes) / sizeof (CursorRestypes[0]))
static Bool
ReplaceCursorLookup(void *value, XID id, void *closure)
{
@@ -645,7 +643,7 @@ ReplaceCursor(CursorPtr pCursor, TestCursorFunc testCursor, void *closure)
for (clientIndex = 0; clientIndex < currentMaxClients; clientIndex++) {
if (!clients[clientIndex])
continue;
for (resIndex = 0; resIndex < NUM_CURSOR_RESTYPES; resIndex++) {
for (resIndex = 0; resIndex < ARRAY_SIZE(CursorRestypes); resIndex++) {
rcl.type = CursorRestypes[resIndex];
/*
* This function walks the entire client resource database