summaryrefslogtreecommitdiff
path: root/Xext
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 /Xext
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 'Xext')
-rw-r--r--Xext/geext.c3
-rw-r--r--Xext/saver.c6
2 files changed, 3 insertions, 6 deletions
diff --git a/Xext/geext.c b/Xext/geext.c
index 08dff280b..5009c081a 100644
--- a/Xext/geext.c
+++ b/Xext/geext.c
@@ -47,7 +47,6 @@ static const int version_requests[] = {
/* Forward declarations */
static void SGEGenericEvent(xEvent *from, xEvent *to);
-#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0]))
#define EXT_MASK(ext) ((ext) & 0x7F)
/************************************************************/
@@ -127,7 +126,7 @@ ProcGEDispatch(ClientPtr client)
REQUEST(xGEReq);
- if (pGEClient->major_version >= NUM_VERSION_REQUESTS)
+ if (pGEClient->major_version >= ARRAY_SIZE(version_requests))
return BadRequest;
if (stuff->ReqType > version_requests[pGEClient->major_version])
return BadRequest;
diff --git a/Xext/saver.c b/Xext/saver.c
index f6090d8da..4d9e6b974 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -1268,14 +1268,12 @@ ProcScreenSaverQueryVersion,
ProcScreenSaverSetAttributes,
ProcScreenSaverUnsetAttributes, ProcScreenSaverSuspend,};
-#define NUM_REQUESTS ((sizeof NormalVector) / (sizeof NormalVector[0]))
-
static int
ProcScreenSaverDispatch(ClientPtr client)
{
REQUEST(xReq);
- if (stuff->data < NUM_REQUESTS)
+ if (stuff->data < ARRAY_SIZE(NormalVector))
return (*NormalVector[stuff->data]) (client);
return BadRequest;
}
@@ -1360,7 +1358,7 @@ SProcScreenSaverDispatch(ClientPtr client)
{
REQUEST(xReq);
- if (stuff->data < NUM_REQUESTS)
+ if (stuff->data < ARRAY_SIZE(NormalVector))
return (*SwappedVector[stuff->data]) (client);
return BadRequest;
}