From 91362071644e1d207cacb5557d96ce2d0f429d05 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 3 Apr 2025 17:50:06 +0200 Subject: [PATCH] dix: write out X_GetAtomName reply directly No need for using a complex callback machinery, if we just move the little pieces of byte-swapping directly into the request handler. Signed-off-by: Enrico Weigelt, metux IT consult --- dix/dispatch.c | 32 ++++++++++++++++++-------------- dix/swaprep.c | 9 --------- dix/tables.c | 2 +- include/swaprep.h | 4 ---- 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 5f6037a94..cdb31c3bb 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -1116,23 +1116,27 @@ ProcGetAtomName(ClientPtr client) REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - if ((str = NameForAtom(stuff->id))) { - int len = strlen(str); - xGetAtomNameReply reply = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = bytes_to_int32(len), - .nameLength = len - }; - - WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply); - WriteToClient(client, len, str); - return Success; - } - else { + if (!(str = NameForAtom(stuff->id))) { client->errorValue = stuff->id; return BadAtom; } + + const int len = strlen(str); + xGetAtomNameReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = bytes_to_int32(len), + .nameLength = len + }; + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swaps(&rep.nameLength); + } + WriteToClient(client, sizeof(rep), &rep); + WriteToClient(client, len, str); + return Success; } int diff --git a/dix/swaprep.c b/dix/swaprep.c index 1657c1749..0c26e966e 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -183,15 +183,6 @@ SGenericReply(ClientPtr pClient, int size, xGenericReply * pRep) WriteToClient(pClient, size, pRep); } -void _X_COLD -SGetAtomNameReply(ClientPtr pClient, int size, xGetAtomNameReply * pRep) -{ - swaps(&pRep->sequenceNumber); - swapl(&pRep->length); - swaps(&pRep->nameLength); - WriteToClient(pClient, size, pRep); -} - void _X_COLD SGetPropertyReply(ClientPtr pClient, int size, xGetPropertyReply * pRep) { diff --git a/dix/tables.c b/dix/tables.c index 56b9fdb8e..1b195790e 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -732,7 +732,7 @@ ReplySwapPtr ReplySwapVector[256] = { ReplyNotSwappd, ReplyNotSwappd, /* 15 */ ReplyNotSwappd, - (ReplySwapPtr) SGetAtomNameReply, + ReplyNotSwappd, ReplyNotSwappd, ReplyNotSwappd, (ReplySwapPtr) SGetPropertyReply, /* 20 */ diff --git a/include/swaprep.h b/include/swaprep.h index ca7e3d9e8..6571dcb26 100644 --- a/include/swaprep.h +++ b/include/swaprep.h @@ -42,10 +42,6 @@ extern void SGenericReply(ClientPtr /* pClient */ , int /* size */ , xGenericReply * /* pRep */ ); -extern void SGetAtomNameReply(ClientPtr /* pClient */ , - int /* size */ , - xGetAtomNameReply * /* pRep */ ); - extern void SGetPropertyReply(ClientPtr /* pClient */ , int /* size */ , xGetPropertyReply * /* pRep */ );