From 9ae97d74876a2d378cc352bdd49e245dc2379a8f Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 1 Apr 2025 15:45:08 +0200 Subject: [PATCH] XI: use SwapLongs() in ProcXGetDeviceMotionEvents() We already have a standard function for swapping 32 bit ints, so let's use this one instead of rolling our own loop. Signed-off-by: Enrico Weigelt, metux IT consult --- Xi/gtmotion.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/Xi/gtmotion.c b/Xi/gtmotion.c index eb57a8c6e..e24dbd769 100644 --- a/Xi/gtmotion.c +++ b/Xi/gtmotion.c @@ -86,13 +86,10 @@ SProcXGetDeviceMotionEvents(ClientPtr client) int ProcXGetDeviceMotionEvents(ClientPtr client) { - INT32 *coords = NULL, *bufptr; - unsigned long i; + INT32 *coords = NULL; int rc, num_events, axes, size = 0; - unsigned long nEvents; DeviceIntPtr dev; TimeStamp start, stop; - int length = 0; ValuatorClassPtr v; REQUEST(xGetDeviceMotionEventsReq); @@ -134,22 +131,16 @@ ProcXGetDeviceMotionEvents(ClientPtr client) start.milliseconds, stop.milliseconds, (ScreenPtr) NULL, FALSE); } - if (rep.nEvents > 0) { - length = bytes_to_int32(rep.nEvents * size); - rep.length = length; + + const int length = rep.nEvents * size; + rep.length = bytes_to_int32(length); + + if (client->swapped) { + SwapLongs((CARD32*) coords, rep.length); } - nEvents = rep.nEvents; + WriteReplyToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep); - if (nEvents) { - if (client->swapped) { - bufptr = coords; - for (i = 0; i < nEvents * (axes + 1); i++) { - swapl(bufptr); - bufptr++; - } - } - WriteToClient(client, length * 4, coords); - } + WriteToClient(client, length, coords); free(coords); return Success; }