From 52bb626cd73e676b8d33ba21239fd512e5d6cd8b Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 9 Jul 2024 10:53:49 +0200 Subject: [PATCH] (submit/cleanup-damageext) damage: don't block requests when version not requested yet The original intention was negotiating versions before any further requests can be processed, so requests that might become incompatible in future versions still can be dispatched correctly. But practically that's never been the case: there's just one major version, and it's unlikely that a new *major* version (that might be incompatible with the current one, using same request codes for different things) will come in the forseeable future. So this extra logic isn't practically needed and just complicates dispatching. Dropping it clears the road for further simplification of the dispatcher. Signed-off-by: Enrico Weigelt, metux IT consult --- damageext/damageext.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/damageext/damageext.c b/damageext/damageext.c index c0432f904..72b8a1487 100644 --- a/damageext/damageext.c +++ b/damageext/damageext.c @@ -467,12 +467,6 @@ ProcDamageAdd(ClientPtr client) return Success; } -/* Major version controls available requests */ -static const int version_requests[] = { - X_DamageQueryVersion, /* before client sends QueryVersion */ - X_DamageAdd, /* Version 1 */ -}; - static int (*ProcDamageVector[XDamageNumberRequests]) (ClientPtr) = { /*************** Version 1 ******************/ ProcDamageQueryVersion, @@ -486,14 +480,12 @@ static int (*ProcDamageVector[XDamageNumberRequests]) (ClientPtr) = { static int ProcDamageDispatch(ClientPtr client) { - REQUEST(xDamageReq); - DamageClientPtr pDamageClient = GetDamageClient(client); + REQUEST(xReq); - if (pDamageClient->major_version >= ARRAY_SIZE(version_requests)) + if (stuff->data >= ARRAY_SIZE(ProcDamageVector)) return BadRequest; - if (stuff->damageReqType > version_requests[pDamageClient->major_version]) - return BadRequest; - return (*ProcDamageVector[stuff->damageReqType]) (client); + + return (*ProcDamageVector[stuff->data]) (client); } static int _X_COLD @@ -559,14 +551,12 @@ static int (*SProcDamageVector[XDamageNumberRequests]) (ClientPtr) = { static int _X_COLD SProcDamageDispatch(ClientPtr client) { - REQUEST(xDamageReq); - DamageClientPtr pDamageClient = GetDamageClient(client); + REQUEST(xReq); - if (pDamageClient->major_version >= ARRAY_SIZE(version_requests)) + if (stuff->data >= ARRAY_SIZE(ProcDamageVector)) return BadRequest; - if (stuff->damageReqType > version_requests[pDamageClient->major_version]) - return BadRequest; - return (*SProcDamageVector[stuff->damageReqType]) (client); + + return (*SProcDamageVector[stuff->data]) (client); } static int