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 <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-29 19:11:13 +02:00 committed by Marge Bot
parent 53d43bd8dc
commit 8789be52a4

View File

@ -727,24 +727,26 @@ ProcRRGetOutputProperty(ClientPtr client)
swapl(&rep.bytesAfter); swapl(&rep.bytesAfter);
swapl(&rep.nItems); swapl(&rep.nItems);
} }
WriteToClient(client, sizeof(rep), &rep);
if (len) { if (len) {
memcpy(extra, (char *) prop_value->data + ind, len); memcpy(extra, (char *) prop_value->data + ind, len);
switch (rep.format) { switch (rep.format) {
case 32: case 32:
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; if (client->swapped)
SwapLongs((CARD32*)extra, len / sizeof(CARD32));
break; break;
case 16: case 16:
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write; if (client->swapped)
SwapShorts((short*)extra, len / sizeof(CARD16));
break; break;
default: default:
client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient;
break; 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 */ if (stuff->delete && (rep.bytesAfter == 0)) { /* delete the Property */
*prev = prop->next; *prev = prop->next;
RRDestroyOutputProperty(prop); RRDestroyOutputProperty(prop);