From fd889145a0a81995e52da810016b0639ea184395 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 3 Jul 2024 19:56:46 +0200 Subject: [PATCH] (!1596) Xext: geext: simplify dispatcher Most of the complexity here isn't needed at all. It can be really trivial, since we just have one operation anyways. It's also much cleaner to use the defines from proto headers instead of raw numbers. Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/geext.c | 49 ++++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/Xext/geext.c b/Xext/geext.c index 4ac852255..c4e213a8d 100644 --- a/Xext/geext.c +++ b/Xext/geext.c @@ -38,12 +38,6 @@ DevPrivateKeyRec GEClientPrivateKeyRec; GEExtension GEExtensions[MAXEXTENSIONS]; -/* Major available requests */ -static const int version_requests[] = { - X_GEQueryVersion, /* before client sends QueryVersion */ - X_GEQueryVersion, /* must be set to last request in version 1 */ -}; - /* Forward declarations */ static void SGEGenericEvent(xEvent *from, xEvent *to); @@ -89,11 +83,6 @@ ProcGEQueryVersion(ClientPtr client) return Success; } -static int (*ProcGEVector[GENumberRequests]) (ClientPtr) = { - /* Version 1.0 */ - ProcGEQueryVersion, -}; - /************************************************************/ /* swapped request handlers */ /************************************************************/ @@ -101,19 +90,12 @@ static int _X_COLD SProcGEQueryVersion(ClientPtr client) { REQUEST(xGEQueryVersionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGEQueryVersionReq); swaps(&stuff->majorVersion); swaps(&stuff->minorVersion); - return (*ProcGEVector[stuff->ReqType]) (client); + return SProcGEQueryVersion(client); } -static int (*SProcGEVector[GENumberRequests]) (ClientPtr) = { - /* Version 1.0 */ - SProcGEQueryVersion -}; - /************************************************************/ /* callbacks */ /************************************************************/ @@ -122,32 +104,29 @@ static int (*SProcGEVector[GENumberRequests]) (ClientPtr) = { static int ProcGEDispatch(ClientPtr client) { - GEClientInfoPtr pGEClient = GEGetClient(client); + REQUEST(xReq); - REQUEST(xGEReq); - - if (pGEClient->major_version >= ARRAY_SIZE(version_requests)) + switch (stuff->data) { + case X_GEQueryVersion: + return ProcGEQueryVersion(client); + default: return BadRequest; - if (stuff->ReqType > version_requests[pGEClient->major_version]) - return BadRequest; - - return (ProcGEVector[stuff->ReqType]) (client); + } } /* dispatch swapped requests */ static int _X_COLD SProcGEDispatch(ClientPtr client) { - GEClientInfoPtr pGEClient = GEGetClient(client); + REQUEST(xReq); + swaps(&stuff->length); - REQUEST(xGEReq); - - if (pGEClient->major_version >= ARRAY_SIZE(version_requests)) + switch (stuff->data) { + case X_GEQueryVersion: + return SProcGEQueryVersion(client); + default: return BadRequest; - if (stuff->ReqType > version_requests[pGEClient->major_version]) - return BadRequest; - - return (*SProcGEVector[stuff->ReqType]) (client); + } } /* Reset extension. Called on server shutdown. */