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 <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1596>
This commit is contained in:
parent
6df7ba38ae
commit
36dd28129b
49
Xext/geext.c
49
Xext/geext.c
|
@ -36,12 +36,6 @@ DevPrivateKeyRec GEClientPrivateKeyRec;
|
||||||
|
|
||||||
GEExtension GEExtensions[MAXEXTENSIONS];
|
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 */
|
/* Forward declarations */
|
||||||
static void SGEGenericEvent(xEvent *from, xEvent *to);
|
static void SGEGenericEvent(xEvent *from, xEvent *to);
|
||||||
|
|
||||||
|
@ -87,11 +81,6 @@ ProcGEQueryVersion(ClientPtr client)
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int (*ProcGEVector[GENumberRequests]) (ClientPtr) = {
|
|
||||||
/* Version 1.0 */
|
|
||||||
ProcGEQueryVersion,
|
|
||||||
};
|
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
/* swapped request handlers */
|
/* swapped request handlers */
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
|
@ -99,19 +88,12 @@ static int _X_COLD
|
||||||
SProcGEQueryVersion(ClientPtr client)
|
SProcGEQueryVersion(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xGEQueryVersionReq);
|
REQUEST(xGEQueryVersionReq);
|
||||||
|
|
||||||
swaps(&stuff->length);
|
|
||||||
REQUEST_SIZE_MATCH(xGEQueryVersionReq);
|
REQUEST_SIZE_MATCH(xGEQueryVersionReq);
|
||||||
swaps(&stuff->majorVersion);
|
swaps(&stuff->majorVersion);
|
||||||
swaps(&stuff->minorVersion);
|
swaps(&stuff->minorVersion);
|
||||||
return (*ProcGEVector[stuff->ReqType]) (client);
|
return SProcGEQueryVersion(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int (*SProcGEVector[GENumberRequests]) (ClientPtr) = {
|
|
||||||
/* Version 1.0 */
|
|
||||||
SProcGEQueryVersion
|
|
||||||
};
|
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
/* callbacks */
|
/* callbacks */
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
|
@ -120,32 +102,29 @@ static int (*SProcGEVector[GENumberRequests]) (ClientPtr) = {
|
||||||
static int
|
static int
|
||||||
ProcGEDispatch(ClientPtr client)
|
ProcGEDispatch(ClientPtr client)
|
||||||
{
|
{
|
||||||
GEClientInfoPtr pGEClient = GEGetClient(client);
|
REQUEST(xReq);
|
||||||
|
|
||||||
REQUEST(xGEReq);
|
switch (stuff->data) {
|
||||||
|
case X_GEQueryVersion:
|
||||||
if (pGEClient->major_version >= ARRAY_SIZE(version_requests))
|
return ProcGEQueryVersion(client);
|
||||||
|
default:
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
if (stuff->ReqType > version_requests[pGEClient->major_version])
|
}
|
||||||
return BadRequest;
|
|
||||||
|
|
||||||
return (ProcGEVector[stuff->ReqType]) (client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dispatch swapped requests */
|
/* dispatch swapped requests */
|
||||||
static int _X_COLD
|
static int _X_COLD
|
||||||
SProcGEDispatch(ClientPtr client)
|
SProcGEDispatch(ClientPtr client)
|
||||||
{
|
{
|
||||||
GEClientInfoPtr pGEClient = GEGetClient(client);
|
REQUEST(xReq);
|
||||||
|
swaps(&stuff->length);
|
||||||
|
|
||||||
REQUEST(xGEReq);
|
switch (stuff->data) {
|
||||||
|
case X_GEQueryVersion:
|
||||||
if (pGEClient->major_version >= ARRAY_SIZE(version_requests))
|
return SProcGEQueryVersion(client);
|
||||||
|
default:
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
if (stuff->ReqType > version_requests[pGEClient->major_version])
|
}
|
||||||
return BadRequest;
|
|
||||||
|
|
||||||
return (*SProcGEVector[stuff->ReqType]) (client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset extension. Called on server shutdown. */
|
/* Reset extension. Called on server shutdown. */
|
||||||
|
|
Loading…
Reference in New Issue