Xext: geext: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros

Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-03 20:02:59 +02:00
parent 07ce669504
commit ff1cb0df89

View File

@ -28,6 +28,7 @@
#include <X11/extensions/ge.h> #include <X11/extensions/ge.h>
#include <X11/extensions/geproto.h> #include <X11/extensions/geproto.h>
#include "dix/request_priv.h"
#include "Xext/geext_priv.h" #include "Xext/geext_priv.h"
#include "windowstr.h" #include "windowstr.h"
@ -67,13 +68,13 @@ static void SGEGenericEvent(xEvent *from, xEvent *to);
static int static int
ProcGEQueryVersion(ClientPtr client) ProcGEQueryVersion(ClientPtr client)
{ {
REQUEST_HEAD_STRUCT(xGEQueryVersionReq);
REQUEST_FIELD_CARD16(majorVersion);
REQUEST_FIELD_CARD16(minorVersion);
GEClientInfoPtr pGEClient = GEGetClient(client); GEClientInfoPtr pGEClient = GEGetClient(client);
xGEQueryVersionReply rep; xGEQueryVersionReply rep;
REQUEST(xGEQueryVersionReq);
REQUEST_SIZE_MATCH(xGEQueryVersionReq);
rep = (xGEQueryVersionReply) { rep = (xGEQueryVersionReply) {
.repType = X_Reply, .repType = X_Reply,
.RepType = X_GEQueryVersion, .RepType = X_GEQueryVersion,
@ -100,19 +101,6 @@ ProcGEQueryVersion(ClientPtr client)
return Success; return Success;
} }
/************************************************************/
/* swapped request handlers */
/************************************************************/
static int _X_COLD
SProcGEQueryVersion(ClientPtr client)
{
REQUEST(xGEQueryVersionReq);
REQUEST_SIZE_MATCH(xGEQueryVersionReq);
swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion);
return ProcGEQueryVersion(client);
}
/************************************************************/ /************************************************************/
/* callbacks */ /* callbacks */
/************************************************************/ /************************************************************/
@ -131,21 +119,6 @@ ProcGEDispatch(ClientPtr client)
} }
} }
/* dispatch swapped requests */
static int _X_COLD
SProcGEDispatch(ClientPtr client)
{
REQUEST(xReq);
swaps(&stuff->length);
switch (stuff->data) {
case X_GEQueryVersion:
return SProcGEQueryVersion(client);
default:
return BadRequest;
}
}
/* Reset extension. Called on server shutdown. */ /* Reset extension. Called on server shutdown. */
static void static void
GEResetProc(ExtensionEntry * extEntry) GEResetProc(ExtensionEntry * extEntry)
@ -186,7 +159,7 @@ GEExtensionInit(void)
(&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec))) (&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec)))
FatalError("GEExtensionInit: GE private request failed.\n"); FatalError("GEExtensionInit: GE private request failed.\n");
if (!AddExtension(GE_NAME, 0, GENumberErrors, ProcGEDispatch, SProcGEDispatch, if (!AddExtension(GE_NAME, 0, GENumberErrors, ProcGEDispatch, ProcGEDispatch,
GEResetProc, StandardMinorOpcode)) GEResetProc, StandardMinorOpcode))
FatalError("GEInit: AddExtensions failed.\n"); FatalError("GEInit: AddExtensions failed.\n");