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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-04-03 19:43:40 +02:00
parent 725bb2d20d
commit f062333422
4 changed files with 30 additions and 37 deletions

View File

@ -2627,8 +2627,12 @@ ProcAllocColor(ClientPtr client)
REQUEST_SIZE_MATCH(xAllocColorReq); REQUEST_SIZE_MATCH(xAllocColorReq);
rc = dixLookupResourceByType((void **) &pmap, stuff->cmap, X11_RESTYPE_COLORMAP, rc = dixLookupResourceByType((void **) &pmap, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixAddAccess); client, DixAddAccess);
if (rc == Success) { if (rc != Success) {
xAllocColorReply acr = { client->errorValue = stuff->cmap;
return rc;
}
xAllocColorReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0, .length = 0,
@ -2637,20 +2641,24 @@ ProcAllocColor(ClientPtr client)
.blue = stuff->blue, .blue = stuff->blue,
.pixel = 0 .pixel = 0
}; };
if ((rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
&acr.pixel, client->index))) if ((rc = AllocColor(pmap, &rep.red, &rep.green, &rep.blue,
&rep.pixel, client->index)))
return rc; return rc;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.red);
swaps(&rep.green);
swaps(&rep.blue);
swapl(&rep.pixel);
}
#ifdef XINERAMA #ifdef XINERAMA
if (noPanoramiXExtension || !pmap->pScreen->myNum) if (noPanoramiXExtension || !pmap->pScreen->myNum)
#endif /* XINERAMA */ #endif /* XINERAMA */
WriteReplyToClient(client, sizeof(xAllocColorReply), &acr); WriteToClient(client, sizeof(rep), &rep);
return Success; return Success;
}
else {
client->errorValue = stuff->cmap;
return rc;
}
} }
int int

View File

@ -310,17 +310,6 @@ SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply * pRep)
WriteToClient(pClient, size, 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 void _X_COLD
SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply * pRep) SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply * pRep)
{ {

View File

@ -799,7 +799,7 @@ ReplySwapPtr ReplySwapVector[256] = {
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
(ReplySwapPtr) SAllocColorReply, ReplyNotSwappd,
(ReplySwapPtr) SAllocNamedColorReply, /* 85 */ (ReplySwapPtr) SAllocNamedColorReply, /* 85 */
(ReplySwapPtr) SAllocColorCellsReply, (ReplySwapPtr) SAllocColorCellsReply,
(ReplySwapPtr) SAllocColorPlanesReply, (ReplySwapPtr) SAllocColorPlanesReply,

View File

@ -68,10 +68,6 @@ extern void SGetFontPathReply(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xGetFontPathReply * /* pRep */ ); xGetFontPathReply * /* pRep */ );
extern void SAllocColorReply(ClientPtr /* pClient */ ,
int /* size */ ,
xAllocColorReply * /* pRep */ );
extern void SAllocNamedColorReply(ClientPtr /* pClient */ , extern void SAllocNamedColorReply(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xAllocNamedColorReply * /* pRep */ xAllocNamedColorReply * /* pRep */