From f0623334225fe2252e03a454b888cebda9589e08 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 3 Apr 2025 19:43:40 +0200 Subject: [PATCH] dix: write out X_AllocColor 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 | 50 +++++++++++++++++++++++++++-------------------- dix/swaprep.c | 11 ----------- dix/tables.c | 2 +- include/swaprep.h | 4 ---- 4 files changed, 30 insertions(+), 37 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index f54240fc7..cf5d9818a 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -2627,30 +2627,38 @@ ProcAllocColor(ClientPtr client) REQUEST_SIZE_MATCH(xAllocColorReq); rc = dixLookupResourceByType((void **) &pmap, stuff->cmap, X11_RESTYPE_COLORMAP, client, DixAddAccess); - if (rc == Success) { - xAllocColorReply acr = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0, - .red = stuff->red, - .green = stuff->green, - .blue = stuff->blue, - .pixel = 0 - }; - if ((rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue, - &acr.pixel, client->index))) - return rc; -#ifdef XINERAMA - if (noPanoramiXExtension || !pmap->pScreen->myNum) -#endif /* XINERAMA */ - WriteReplyToClient(client, sizeof(xAllocColorReply), &acr); - return Success; - - } - else { + if (rc != Success) { client->errorValue = stuff->cmap; return rc; } + + xAllocColorReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .red = stuff->red, + .green = stuff->green, + .blue = stuff->blue, + .pixel = 0 + }; + + if ((rc = AllocColor(pmap, &rep.red, &rep.green, &rep.blue, + &rep.pixel, client->index))) + return rc; + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swaps(&rep.red); + swaps(&rep.green); + swaps(&rep.blue); + swapl(&rep.pixel); + } + +#ifdef XINERAMA + if (noPanoramiXExtension || !pmap->pScreen->myNum) +#endif /* XINERAMA */ + WriteToClient(client, sizeof(rep), &rep); + return Success; } int diff --git a/dix/swaprep.c b/dix/swaprep.c index 6a875a99d..83fe86e8d 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -310,17 +310,6 @@ SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply * pRep) WriteToClient(pClient, size, pRep); } -void _X_COLD -SAllocColorReply(ClientPtr pClient, int size, xAllocColorReply * pRep) -{ - swaps(&pRep->sequenceNumber); - swaps(&pRep->red); - swaps(&pRep->green); - swaps(&pRep->blue); - swapl(&pRep->pixel); - WriteToClient(pClient, size, pRep); -} - void _X_COLD SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply * pRep) { diff --git a/dix/tables.c b/dix/tables.c index 970d8e5e0..79c5a8fb5 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -799,7 +799,7 @@ ReplySwapPtr ReplySwapVector[256] = { ReplyNotSwappd, ReplyNotSwappd, ReplyNotSwappd, - (ReplySwapPtr) SAllocColorReply, + ReplyNotSwappd, (ReplySwapPtr) SAllocNamedColorReply, /* 85 */ (ReplySwapPtr) SAllocColorCellsReply, (ReplySwapPtr) SAllocColorPlanesReply, diff --git a/include/swaprep.h b/include/swaprep.h index d362bac55..212812fce 100644 --- a/include/swaprep.h +++ b/include/swaprep.h @@ -68,10 +68,6 @@ extern void SGetFontPathReply(ClientPtr /* pClient */ , int /* size */ , xGetFontPathReply * /* pRep */ ); -extern void SAllocColorReply(ClientPtr /* pClient */ , - int /* size */ , - xAllocColorReply * /* pRep */ ); - extern void SAllocNamedColorReply(ClientPtr /* pClient */ , int /* size */ , xAllocNamedColorReply * /* pRep */