From 6413bd61d741975075729f6cbffc39355f4169d5 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 28 Aug 2025 16:37:57 +0200 Subject: [PATCH] Xi: ProcXGetFeedbackControl(): use x_rpcbuf_t Use x_rpcbuf_t for reply payload assembly. Signed-off-by: Enrico Weigelt, metux IT consult --- Xi/getfctl.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/Xi/getfctl.c b/Xi/getfctl.c index 64dab777a..b19783a21 100644 --- a/Xi/getfctl.c +++ b/Xi/getfctl.c @@ -52,9 +52,13 @@ SOFTWARE. #include -#include "inputstr.h" /* DeviceIntPtr */ #include #include + +#include "dix/dix_priv.h" +#include "dix/rpcbuf_priv.h" + +#include "inputstr.h" /* DeviceIntPtr */ #include "exglobals.h" #include "getfctl.h" @@ -244,7 +248,6 @@ int ProcXGetFeedbackControl(ClientPtr client) { int rc, total_length = 0; - char *savbuf; DeviceIntPtr dev; KbdFeedbackPtr k; PtrFeedbackPtr p; @@ -261,9 +264,7 @@ ProcXGetFeedbackControl(ClientPtr client) return rc; xGetFeedbackControlReply rep = { - .repType = X_Reply, .RepType = X_GetFeedbackControl, - .sequenceNumber = client->sequence, }; for (k = dev->kbdfeed; k; k = k->next) { @@ -295,10 +296,8 @@ ProcXGetFeedbackControl(ClientPtr client) if (total_length == 0) return BadMatch; - char *buf = (char *) calloc(1, total_length); - if (!buf) - return BadAlloc; - savbuf = buf; + x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE }; + char *buf = x_rpcbuf_reserve(&rpcbuf, total_length); for (k = dev->kbdfeed; k; k = k->next) CopySwapKbdFeedback(client, k, &buf); @@ -313,15 +312,8 @@ ProcXGetFeedbackControl(ClientPtr client) for (b = dev->bell; b; b = b->next) CopySwapBellFeedback(client, b, &buf); - rep.length = bytes_to_int32(total_length); - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swaps(&rep.num_feedbacks); } - WriteToClient(client, sizeof(xGetFeedbackControlReply), &rep); - WriteToClient(client, total_length, savbuf); - free(savbuf); - return Success; + return X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); }