From 6148bee17d563a1b9acfb061b59b49e704359eb9 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 10 Sep 2025 13:27:43 +0200 Subject: [PATCH] xfree86: dga: ProcXDGASetMode(): use x_rpcbuf_t Use x_rpcbuf_t for payload assembly and X_SEND_REPLY_WITH_RPCBUF() for sending it all out. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xfree86/common/xf86DGA.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 4b4681ddf..8214e58a9 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -1330,12 +1330,10 @@ static int ProcXDGASetMode(ClientPtr client) { REQUEST(xXDGASetModeReq); - xXDGASetModeReply rep; XDGAModeRec mode; xXDGAModeInfo info; PixmapPtr pPix; ClientPtr owner; - int size; REQUEST_SIZE_MATCH(xXDGASetModeReq); @@ -1343,18 +1341,14 @@ ProcXDGASetMode(ClientPtr client) return BadValue; owner = DGA_GETCLIENT(stuff->screen); - rep.type = X_Reply; - rep.length = 0; - rep.offset = 0; - rep.flags = 0; - rep.sequenceNumber = client->sequence; - if (!DGAAvailable(stuff->screen)) return DGAErrorBase + XF86DGANoDirectVideoMode; if (owner && owner != client) return DGAErrorBase + XF86DGANoDirectVideoMode; + xXDGASetModeReply rep = { 0 }; + if (!stuff->mode) { if (owner) { if (--DGACallbackRefCount == 0) @@ -1384,13 +1378,11 @@ ProcXDGASetMode(ClientPtr client) } } - size = strlen(mode.name) + 1; - info.byte_order = mode.byteOrder; info.depth = mode.depth; info.num = mode.num; info.bpp = mode.bitsPerPixel; - info.name_size = (size + 3) & ~3L; + info.name_size = ((strlen(mode.name) + 1) + 3) & ~3L; info.vsync_num = mode.VSync_num; info.vsync_den = mode.VSync_den; info.flags = mode.flags; @@ -1413,13 +1405,11 @@ ProcXDGASetMode(ClientPtr client) info.reserved1 = mode.reserved1; info.reserved2 = mode.reserved2; - rep.length = bytes_to_int32(sz_xXDGAModeInfo + info.name_size); + x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE }; + x_rpcbuf_write_binary_pad(&rpcbuf, &info, sizeof(info)); + x_rpcbuf_write_string_0t_pad(&rpcbuf, mode.name); - WriteToClient(client, sz_xXDGASetModeReply, (char *) &rep); - WriteToClient(client, sz_xXDGAModeInfo, (char *) (&info)); - WriteToClient(client, size, mode.name); - - return Success; + return X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); } static int