dix: write out X_AllocColorPlanes 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 14:42:30 +02:00
parent 3a233ac98a
commit 6e657b2ca5
4 changed files with 19 additions and 27 deletions

View File

@ -2795,7 +2795,6 @@ ProcAllocColorPlanes(ClientPtr client)
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP, rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixAddAccess); client, DixAddAccess);
if (rc == Success) { if (rc == Success) {
xAllocColorPlanesReply acpr;
int npixels; int npixels;
long length; long length;
@ -2808,7 +2807,8 @@ ProcAllocColorPlanes(ClientPtr client)
client->errorValue = stuff->contiguous; client->errorValue = stuff->contiguous;
return BadValue; return BadValue;
} }
acpr = (xAllocColorPlanesReply) {
xAllocColorPlanesReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.nPixels = npixels .nPixels = npixels
@ -2821,19 +2821,29 @@ ProcAllocColorPlanes(ClientPtr client)
if ((rc = AllocColorPlanes(client->index, pcmp, npixels, if ((rc = AllocColorPlanes(client->index, pcmp, npixels,
(int) stuff->red, (int) stuff->green, (int) stuff->red, (int) stuff->green,
(int) stuff->blue, (Bool) stuff->contiguous, (int) stuff->blue, (Bool) stuff->contiguous,
ppixels, &acpr.redMask, &acpr.greenMask, ppixels, &rep.redMask, &rep.greenMask,
&acpr.blueMask))) { &rep.blueMask))) {
free(ppixels); free(ppixels);
return rc; return rc;
} }
acpr.length = bytes_to_int32(length); rep.length = bytes_to_int32(length);
if (client->swapped) {
SwapLongs(ppixels, rep.length);
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.nPixels);
swapl(&rep.redMask);
swapl(&rep.greenMask);
swapl(&rep.blueMask);
}
#ifdef XINERAMA #ifdef XINERAMA
if (noPanoramiXExtension || !pcmp->pScreen->myNum) if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif /* XINERAMA */ #endif /* XINERAMA */
{ {
WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr); WriteToClient(client, sizeof(rep), &rep);
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteToClient(client, length, ppixels);
WriteSwappedDataToClient(client, length, ppixels);
} }
free(ppixels); free(ppixels);
return Success; return Success;

View File

@ -310,19 +310,6 @@ SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply * pRep)
WriteToClient(pClient, size, pRep); WriteToClient(pClient, size, pRep);
} }
void _X_COLD
SAllocColorPlanesReply(ClientPtr pClient, int size,
xAllocColorPlanesReply * pRep)
{
swaps(&pRep->sequenceNumber);
swapl(&pRep->length);
swaps(&pRep->nPixels);
swapl(&pRep->redMask);
swapl(&pRep->greenMask);
swapl(&pRep->blueMask);
WriteToClient(pClient, size, pRep);
}
static void _X_COLD static void _X_COLD
SwapRGB(xrgb * prgb) SwapRGB(xrgb * prgb)
{ {

View File

@ -802,7 +802,7 @@ ReplySwapPtr ReplySwapVector[256] = {
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, /* 85 */ ReplyNotSwappd, /* 85 */
ReplyNotSwappd, ReplyNotSwappd,
(ReplySwapPtr) SAllocColorPlanesReply, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, /* 90 */ ReplyNotSwappd, /* 90 */

View File

@ -68,11 +68,6 @@ extern void SGetFontPathReply(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xGetFontPathReply * /* pRep */ ); xGetFontPathReply * /* pRep */ );
extern void SAllocColorPlanesReply(ClientPtr /* pClient */ ,
int /* size */ ,
xAllocColorPlanesReply * /* pRep */
);
extern void SQColorsExtend(ClientPtr /* pClient */ , extern void SQColorsExtend(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xrgb * /* prgb */ ); xrgb * /* prgb */ );