dix: write out X_ListExtensions 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-04 18:59:02 +02:00
parent a1e5033170
commit fc13768c3e
4 changed files with 11 additions and 20 deletions

View File

@ -258,13 +258,12 @@ ProcQueryExtension(ClientPtr client)
int
ProcListExtensions(ClientPtr client)
{
xListExtensionsReply reply;
char *bufptr, *buffer;
int total_length = 0;
REQUEST_SIZE_MATCH(xReq);
reply = (xListExtensionsReply) {
xListExtensionsReply rep = {
.type = X_Reply,
.nExtensions = 0,
.sequenceNumber = client->sequence,
@ -281,9 +280,9 @@ ProcListExtensions(ClientPtr client)
continue;
total_length += strlen(extensions[i]->name) + 1;
reply.nExtensions += 1;
rep.nExtensions += 1;
}
reply.length = bytes_to_int32(total_length);
rep.length = bytes_to_int32(total_length);
buffer = bufptr = calloc(1, total_length);
if (!buffer)
return BadAlloc;
@ -298,9 +297,13 @@ ProcListExtensions(ClientPtr client)
bufptr += len;
}
}
WriteReplyToClient(client, sizeof(xListExtensionsReply), &reply);
if (reply.length)
WriteToClient(client, total_length, buffer);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, total_length, buffer);
free(buffer);
return Success;

View File

@ -279,14 +279,6 @@ SwapFont(xQueryFontReply * pr, Bool hasGlyphs)
}
}
void _X_COLD
SListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply * pRep)
{
swaps(&pRep->sequenceNumber);
swapl(&pRep->length);
WriteToClient(pClient, size, pRep);
}
void _X_COLD
SErrorEvent(xError * from, xError * to)
{

View File

@ -814,7 +814,7 @@ ReplySwapPtr ReplySwapVector[256] = {
ReplyNotSwappd,
ReplyNotSwappd,
ReplyNotSwappd,
(ReplySwapPtr) SListExtensionsReply,
ReplyNotSwappd,
ReplyNotSwappd, /* 100 */
ReplyNotSwappd,
ReplyNotSwappd,

View File

@ -55,10 +55,6 @@ extern void SwapTimeCoordWrite(ClientPtr /* pClient */ ,
int /* size */ ,
xTimecoord * /* pRep */ );
extern void SListExtensionsReply(ClientPtr /* pClient */ ,
int /* size */ ,
xListExtensionsReply * /* pRep */ );
extern void SErrorEvent(xError * /* from */ ,
xError * /* to */ );