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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-04-03 17:50:06 +02:00
parent 56f1c26056
commit 9136207164
4 changed files with 19 additions and 28 deletions

View File

@ -1116,24 +1116,28 @@ ProcGetAtomName(ClientPtr client)
REQUEST(xResourceReq); REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
if ((str = NameForAtom(stuff->id))) { if (!(str = NameForAtom(stuff->id))) {
int len = strlen(str); client->errorValue = stuff->id;
xGetAtomNameReply reply = { return BadAtom;
}
const int len = strlen(str);
xGetAtomNameReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = bytes_to_int32(len), .length = bytes_to_int32(len),
.nameLength = len .nameLength = len
}; };
WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply); if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.nameLength);
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, len, str); WriteToClient(client, len, str);
return Success; return Success;
} }
else {
client->errorValue = stuff->id;
return BadAtom;
}
}
int int
ProcGrabServer(ClientPtr client) ProcGrabServer(ClientPtr client)

View File

@ -183,15 +183,6 @@ SGenericReply(ClientPtr pClient, int size, xGenericReply * pRep)
WriteToClient(pClient, size, 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 void _X_COLD
SGetPropertyReply(ClientPtr pClient, int size, xGetPropertyReply * pRep) SGetPropertyReply(ClientPtr pClient, int size, xGetPropertyReply * pRep)
{ {

View File

@ -732,7 +732,7 @@ ReplySwapPtr ReplySwapVector[256] = {
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, /* 15 */ ReplyNotSwappd, /* 15 */
ReplyNotSwappd, ReplyNotSwappd,
(ReplySwapPtr) SGetAtomNameReply, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
(ReplySwapPtr) SGetPropertyReply, /* 20 */ (ReplySwapPtr) SGetPropertyReply, /* 20 */

View File

@ -42,10 +42,6 @@ extern void SGenericReply(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xGenericReply * /* pRep */ ); xGenericReply * /* pRep */ );
extern void SGetAtomNameReply(ClientPtr /* pClient */ ,
int /* size */ ,
xGetAtomNameReply * /* pRep */ );
extern void SGetPropertyReply(ClientPtr /* pClient */ , extern void SGetPropertyReply(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xGetPropertyReply * /* pRep */ ); xGetPropertyReply * /* pRep */ );