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,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

View File

@ -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)
{

View File

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

View File

@ -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 */ );