From 7aa06ee749aaa3266a198882ab3e8d8fa3f0dda2 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 22 Aug 2025 19:01:32 +0200 Subject: [PATCH] Xext: replace WriteRpcbufToClient() by X_SEND_REPLY_WITH_RPCBUF() macro Use the new X_SEND_REPLY_WITH_RPCBUF() macro for final reply write out. Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/panoramiX.c | 8 +------- Xext/panoramiXprocs.c | 7 +------ Xext/vidmode.c | 29 +++-------------------------- Xext/xcmisc.c | 8 +------- Xext/xf86bigfont.c | 14 +------------- Xext/xvdisp.c | 40 +++++----------------------------------- 6 files changed, 12 insertions(+), 94 deletions(-) diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index afc2e69fd8..8d2035aa24 100644 --- a/Xext/panoramiX.c +++ b/Xext/panoramiX.c @@ -1029,17 +1029,12 @@ ProcXineramaQueryScreens(ClientPtr client) /* REQUEST(xXineramaQueryScreensReq); */ CARD32 number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens; xXineramaQueryScreensReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = bytes_to_int32(number * sz_XineramaScreenInfo), .number = number }; REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swapl(&rep.number); } @@ -1061,8 +1056,7 @@ ProcXineramaQueryScreens(ClientPtr client) } } - WriteToClient(client, sizeof(xXineramaQueryScreensReply), &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); return Success; } diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index a977c240dd..ffee038016 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -2120,21 +2120,16 @@ PanoramiXGetImage(ClientPtr client) } xGetImageReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .visual = wVisual(((WindowPtr) pDraw)), .depth = pDraw->depth, - .length = bytes_to_int32(length), }; if (client->swapped) { swaps(&rep.sequenceNumber); - swapl(&rep.length); swapl(&rep.visual); } - WriteToClient(client, sizeof(rep), &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); return Success; } diff --git a/Xext/vidmode.c b/Xext/vidmode.c index ee78b4eb33..b452f1abfd 100644 --- a/Xext/vidmode.c +++ b/Xext/vidmode.c @@ -392,21 +392,14 @@ ProcVidModeGetAllModeLines(ClientPtr client) return BadAlloc; xXF86VidModeGetAllModeLinesReply rep = { - .type = X_Reply, - .length = X_REPLY_HEADER_UNITS(xXF86VidModeGetAllModeLinesReply) - + x_rpcbuf_wsize_units(&rpcbuf), - .sequenceNumber = client->sequence, .modecount = modecount }; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swapl(&rep.modecount); } - WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); return Success; } @@ -1249,23 +1242,13 @@ ProcVidModeGetMonitor(ClientPtr client) return BadAlloc; xXF86VidModeGetMonitorReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .nhsync = nHsync, .nvsync = nVrefresh, .vendorLength = x_safe_strlen(vendorStr), .modelLength = x_safe_strlen(modelStr), - .length = X_REPLY_HEADER_UNITS(xXF86VidModeGetMonitorReply) + - x_rpcbuf_wsize_units(&rpcbuf) }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - - WriteToClient(client, sizeof(xXF86VidModeGetMonitorReply), &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); return Success; } @@ -1381,24 +1364,18 @@ ProcVidModeGetDotClocks(ClientPtr client) return BadAlloc; xXF86VidModeGetDotClocksReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = X_REPLY_HEADER_UNITS(xXF86VidModeGetDotClocksReply) + numClocks, .clocks = numClocks, .maxclocks = MAXCLOCKS, .flags = (ClockProg ? CLKFLAG_PROGRAMABLE : 0), }; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swapl(&rep.clocks); swapl(&rep.maxclocks); swapl(&rep.flags); } - WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); return Success; } diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c index 108ae257a4..a638a76026 100644 --- a/Xext/xcmisc.c +++ b/Xext/xcmisc.c @@ -116,19 +116,13 @@ ProcXCMiscGetXIDList(ClientPtr client) return BadAlloc; xXCMiscGetXIDListReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = count, .count = count }; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swapl(&rep.count); } - WriteToClient(client, sizeof(xXCMiscGetXIDListReply), &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); return Success; } diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index f2c28e7aa9..b06ca69f17 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -527,16 +527,7 @@ ProcXF86BigfontQueryFont(ClientPtr client) { int nfontprops = pFont->info.nprops; - int rlength = nfontprops * sizeof(xFontProp) - + (nCharInfos > 0 && shmid == -1 - ? nUniqCharInfos * sizeof(xCharInfo) - + (nCharInfos + 1) / 2 * 2 * sizeof(CARD16) - : 0); - xXF86BigfontQueryFontReply rep = { - .type = X_Reply, - .length = X_REPLY_HEADER_UNITS(xXF86BigfontQueryFontReply) + rlength, - .sequenceNumber = client->sequence, .minBounds = pFont->info.ink_minbounds, .maxBounds = pFont->info.ink_maxbounds, .minCharOrByte2 = pFont->info.firstCol, @@ -555,8 +546,6 @@ ProcXF86BigfontQueryFont(ClientPtr client) }; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swapCharInfo(&rep.minBounds); swapCharInfo(&rep.maxBounds); swaps(&rep.minCharOrByte2); @@ -591,8 +580,7 @@ ProcXF86BigfontQueryFont(ClientPtr client) goto out; } - WriteToClient(client, sizeof(xXF86BigfontQueryFontReply), &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); out: if (nCharInfos > 0) { if (shmid == -1) diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c index 07953da9d3..21e1541a44 100644 --- a/Xext/xvdisp.c +++ b/Xext/xvdisp.c @@ -128,20 +128,14 @@ ProcXvQueryAdaptors(ClientPtr client) } xvQueryAdaptorsReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .num_adaptors = numAdaptors, - .length = x_rpcbuf_wsize_units(&rpcbuf) }; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swaps(&rep.num_adaptors); } - WriteToClient(client, sizeof(rep), &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); return Success; } @@ -176,20 +170,14 @@ ProcXvQueryEncodings(ClientPtr client) return BadAlloc; xvQueryEncodingsReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .num_encodings = pPort->pAdaptor->nEncodings, - .length = x_rpcbuf_wsize_units(&rpcbuf), }; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swaps(&rep.num_encodings); } - WriteToClient(client, sizeof(rep), &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); return Success; } @@ -568,22 +556,16 @@ ProcXvQueryPortAttributes(ClientPtr client) return BadAlloc; xvQueryPortAttributesReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .num_attributes = pPort->pAdaptor->nAttributes, - .length = x_rpcbuf_wsize_units(&rpcbuf), .text_size = textSize, }; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swapl(&rep.num_attributes); swapl(&rep.text_size); } - WriteToClient(client, sizeof(rep), &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); return Success; } @@ -804,9 +786,6 @@ ProcXvQueryImageAttributes(ClientPtr client) pitches); xvQueryImageAttributesReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = x_rpcbuf_wsize_units(&rpcbuf), .num_planes = num_planes, .width = width, .height = height, @@ -814,8 +793,6 @@ ProcXvQueryImageAttributes(ClientPtr client) }; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swapl(&rep.num_planes); swapl(&rep.data_size); swaps(&rep.width); @@ -825,8 +802,7 @@ ProcXvQueryImageAttributes(ClientPtr client) SwapLongs((CARD32 *) offsets, x_rpcbuf_wsize_units(&rpcbuf)); } - WriteToClient(client, sz_xvQueryImageAttributesReply, &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); return Success; } @@ -891,20 +867,14 @@ ProcXvListImageFormats(ClientPtr client) rpcbuf.wpos, (pPort->pAdaptor->nImages*sz_xvImageFormatInfo)); xvListImageFormatsReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .num_formats = pPort->pAdaptor->nImages, - .length = x_rpcbuf_wsize_units(&rpcbuf) }; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swapl(&rep.num_formats); } - WriteToClient(client, sz_xvListImageFormatsReply, &rep); - WriteRpcbufToClient(client, &rpcbuf); + X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); return Success; }