From baac2944f64d4354699bc063deedbf85a601d284 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 31 Mar 2025 14:54:23 +0200 Subject: [PATCH] XI: directly write out X_OpenDevice reply Write out X_OpenDevice the reply directly (and do the swapping within the request handler) instead of going through separate callback that's having demux the replies again. Signed-off-by: Enrico Weigelt, metux IT consult --- Xi/extinit.c | 4 +--- Xi/opendev.c | 23 +++++++---------------- Xi/opendev.h | 5 ----- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/Xi/extinit.c b/Xi/extinit.c index cd445eb6d..7b8f6ad49 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -421,9 +421,7 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) { /* All we look at is the type field */ /* This is common to all replies */ - if (rep->RepType == X_OpenDevice) - SRepXOpenDevice(client, len, (xOpenDeviceReply *) rep); - else if (rep->RepType == X_SetDeviceMode) + if (rep->RepType == X_SetDeviceMode) SRepXSetDeviceMode(client, len, (xSetDeviceModeReply *) rep); else if (rep->RepType == X_GetSelectedExtensionEvents) SRepXGetSelectedExtensionEvents(client, len, diff --git a/Xi/opendev.c b/Xi/opendev.c index f768b997d..2e7b28bab 100644 --- a/Xi/opendev.c +++ b/Xi/opendev.c @@ -137,22 +137,13 @@ ProcXOpenDevice(ClientPtr client) .length = bytes_to_int32(j * sizeof(xInputClassInfo)), .num_classes = j }; - WriteReplyToClient(client, sizeof(xOpenDeviceReply), &rep); + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + } + + WriteToClient(client, sizeof(xOpenDeviceReply), &rep); WriteToClient(client, j * sizeof(xInputClassInfo), evbase); return Success; } - -/*********************************************************************** - * - * This procedure writes the reply for the XOpenDevice function, - * if the client and server have a different byte ordering. - * - */ - -void _X_COLD -SRepXOpenDevice(ClientPtr client, int size, xOpenDeviceReply * rep) -{ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - WriteToClient(client, size, rep); -} diff --git a/Xi/opendev.h b/Xi/opendev.h index 641dd7862..89b326d43 100644 --- a/Xi/opendev.h +++ b/Xi/opendev.h @@ -33,9 +33,4 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. int ProcXOpenDevice(ClientPtr /* client */ ); -void SRepXOpenDevice(ClientPtr /* client */ , - int /* size */ , - xOpenDeviceReply * /* rep */ - ); - #endif /* OPENDEV_H */