From 8789be52a4ce4a285636f8c4efc2bd196fe571a2 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 29 Jul 2024 19:11:13 +0200 Subject: [PATCH] randr: ProcRRGetOutputProperty(): use SwapShort()/SwapLong() Simplify reply payload preparation and sendout by using SwapShort() and SwapLong() instead of WriteToClientSwapped() and callbacks. This also allows even further simplifications by using generic macros for the request send path. Signed-off-by: Enrico Weigelt, metux IT consult Part-of: --- randr/rrproperty.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 315e5b275..122f5ab64 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -727,24 +727,26 @@ ProcRRGetOutputProperty(ClientPtr client) swapl(&rep.bytesAfter); swapl(&rep.nItems); } - WriteToClient(client, sizeof(rep), &rep); if (len) { memcpy(extra, (char *) prop_value->data + ind, len); switch (rep.format) { case 32: - client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; + if (client->swapped) + SwapLongs((CARD32*)extra, len / sizeof(CARD32)); break; case 16: - client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write; + if (client->swapped) + SwapShorts((short*)extra, len / sizeof(CARD16)); break; default: - client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient; break; } - WriteSwappedDataToClient(client, len, extra); - free(extra); } + WriteToClient(client, sizeof(rep), &rep); + WriteToClient(client, len, extra); + free(extra); + if (stuff->delete && (rep.bytesAfter == 0)) { /* delete the Property */ *prev = prop->next; RRDestroyOutputProperty(prop);