From 3eaf92fa429baad4867230d199f1288c0b3bcbdd Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 29 Jul 2024 19:30:03 +0200 Subject: [PATCH] (!1794) randr: ProcRRGetProviderProperty(): 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 --- randr/rrproviderproperty.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c index 45e9a63e65..fc78a0c7cb 100644 --- a/randr/rrproviderproperty.c +++ b/randr/rrproviderproperty.c @@ -685,24 +685,25 @@ ProcRRGetProviderProperty(ClientPtr client) swapl(&reply.bytesAfter); swapl(&reply.nItems); } - WriteToClient(client, sizeof(xGenericReply), &reply); if (len) { memcpy(extra, (char *) prop_value->data + ind, len); switch (reply.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(xGenericReply), &reply); + WriteToClient(client, len, extra); + + if (extra) free(extra); + if (stuff->delete && (reply.bytesAfter == 0)) { /* delete the Property */ *prev = prop->next; RRDestroyProviderProperty(prop);