From ccbb4315a14beecf7ac0ecf04e5c95aad895fef0 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 12 Jul 2024 15:05:33 +0200 Subject: [PATCH] xfixes: use REPLY_*() macros for preparing / sending replies Use the new macros for preparing and sending replies to clients. Signed-off-by: Enrico Weigelt, metux IT consult --- xfixes/cursor.c | 70 +++++++++++++++------------------------------ xfixes/disconnect.c | 11 ++----- xfixes/region.c | 20 ++++--------- xfixes/xfixes.c | 18 ++++-------- 4 files changed, 36 insertions(+), 83 deletions(-) diff --git a/xfixes/cursor.c b/xfixes/cursor.c index 0ca02ce4f9..8b2e296437 100644 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -375,8 +375,6 @@ ProcXFixesGetCursorImage(ClientPtr client) CopyCursorToImage(pCursor, image); xXFixesGetCursorImageReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .length = npixels, .width = width, .height = height, @@ -387,20 +385,15 @@ ProcXFixesGetCursorImage(ClientPtr client) .cursorSerial = pCursor->serialNumber, }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.x); - swaps(&rep.y); - swaps(&rep.width); - swaps(&rep.height); - swaps(&rep.xhot); - swaps(&rep.yhot); - swapl(&rep.cursorSerial); - SwapLongs(image, npixels); - } - WriteToClient(client, sizeof(xXFixesGetCursorImageReply), &rep); - WriteToClient(client, sizeof(image), image); + REPLY_FIELD_CARD16(x); + REPLY_FIELD_CARD16(y); + REPLY_FIELD_CARD16(width); + REPLY_FIELD_CARD16(height); + REPLY_FIELD_CARD16(xhot); + REPLY_FIELD_CARD16(yhot); + REPLY_FIELD_CARD32(cursorSerial); + REPLY_BUF_CARD32(image, npixels); + REPLY_SEND_EXTRA(image, sizeof(image)); return Success; } @@ -444,21 +437,12 @@ ProcXFixesGetCursorName(ClientPtr client) len = strlen(str); xXFixesGetCursorNameReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = bytes_to_int32(len), .atom = pCursor->name, .nbytes = len }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.atom); - swaps(&rep.nbytes); - } - WriteReplyToClient(client, sizeof(xXFixesGetCursorNameReply), &rep); - WriteToClient(client, len, str); - + REPLY_FIELD_CARD32(atom); + REPLY_FIELD_CARD16(nbytes); + REPLY_SEND_EXTRA(str, len); return Success; } @@ -496,9 +480,6 @@ ProcXFixesGetCursorImageAndName(ClientPtr client) memcpy((image + npixels), name, nbytes); xXFixesGetCursorImageAndNameReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = bytes_to_int32(sizeof(image)), .width = width, .height = height, .x = x, @@ -510,22 +491,17 @@ ProcXFixesGetCursorImageAndName(ClientPtr client) .nbytes = nbytes, }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.x); - swaps(&rep.y); - swaps(&rep.width); - swaps(&rep.height); - swaps(&rep.xhot); - swaps(&rep.yhot); - swapl(&rep.cursorSerial); - swapl(&rep.cursorName); - swaps(&rep.nbytes); - SwapLongs(image, npixels); - } - WriteToClient(client, sizeof(xXFixesGetCursorImageAndNameReply), &rep); - WriteToClient(client, sizeof(image), image); + REPLY_FIELD_CARD16(x); + REPLY_FIELD_CARD16(y); + REPLY_FIELD_CARD16(width); + REPLY_FIELD_CARD16(height); + REPLY_FIELD_CARD16(xhot); + REPLY_FIELD_CARD16(yhot); + REPLY_FIELD_CARD32(cursorSerial); + REPLY_FIELD_CARD32(cursorName); + REPLY_FIELD_CARD16(nbytes); + REPLY_BUF_CARD32(image, npixels); + REPLY_SEND_EXTRA(image, sizeof(image)); return Success; } diff --git a/xfixes/disconnect.c b/xfixes/disconnect.c index ae0d276bde..a225913c2f 100644 --- a/xfixes/disconnect.c +++ b/xfixes/disconnect.c @@ -83,18 +83,11 @@ ProcXFixesGetClientDisconnectMode(ClientPtr client) ClientDisconnectPtr pDisconnect = GetClientDisconnect(client); xXFixesGetClientDisconnectModeReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0, .disconnect_mode = pDisconnect->disconnect_mode, }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.disconnect_mode); - } - WriteToClient(client, sizeof(xXFixesGetClientDisconnectModeReply), &rep); - return Success; + REPLY_FIELD_CARD32(disconnect_mode); + REPLY_SEND_RET_SUCCESS(); } Bool diff --git a/xfixes/region.c b/xfixes/region.c index 9576b5b352..3e01a27267 100644 --- a/xfixes/region.c +++ b/xfixes/region.c @@ -427,26 +427,18 @@ ProcXFixesFetchRegion(ClientPtr client) } xXFixesFetchRegionReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = nBox << 1, .x = pExtent->x1, .y = pExtent->y1, .width = pExtent->x2 - pExtent->x1, .height = pExtent->y2 - pExtent->y1, }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.x); - swaps(&rep.y); - swaps(&rep.width); - swaps(&rep.height); - SwapShorts((INT16 *) pRect, nBox * 4); - } - WriteToClient(client, sizeof(xXFixesFetchRegionReply), &rep); - WriteToClient(client, sizeof(pRect), pRect); + REPLY_FIELD_CARD16(x); + REPLY_FIELD_CARD16(y); + REPLY_FIELD_CARD16(width); + REPLY_FIELD_CARD16(height); + REPLY_BUF_CARD16(pRect, nBox * 4); + REPLY_SEND_EXTRA(pRect, sizeof(pRect)); return Success; } diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c index ef4e7ff0aa..1680bb1142 100644 --- a/xfixes/xfixes.c +++ b/xfixes/xfixes.c @@ -69,11 +69,7 @@ ProcXFixesQueryVersion(ClientPtr client) int major, minor; XFixesClientPtr pXFixesClient = GetXFixesClient(client); - xXFixesQueryVersionReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0 - }; + xXFixesQueryVersionReply rep = { 0 }; if (version_compare(stuff->majorVersion, stuff->minorVersion, SERVER_XFIXES_MAJOR_VERSION, @@ -89,14 +85,10 @@ ProcXFixesQueryVersion(ClientPtr client) pXFixesClient->major_version = major; rep.majorVersion = min(stuff->majorVersion, major); rep.minorVersion = minor; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.majorVersion); - swapl(&rep.minorVersion); - } - WriteToClient(client, sizeof(xXFixesQueryVersionReply), &rep); - return Success; + + REPLY_FIELD_CARD32(majorVersion); + REPLY_FIELD_CARD32(minorVersion); + REPLY_SEND_RET_SUCCESS(); } /* Major version controls available requests */