From 9d40106aaa1a6e60e78dafe19d1911ded3d82e29 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 17 Jul 2024 10:51:55 +0200 Subject: [PATCH] dbe: 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 --- Xext/xres.c | 2 +- dbe/dbe.c | 76 ++++++++++++----------------------------------------- 2 files changed, 18 insertions(+), 60 deletions(-) diff --git a/Xext/xres.c b/Xext/xres.c index 15d2ea7320..5875e17828 100644 --- a/Xext/xres.c +++ b/Xext/xres.c @@ -423,7 +423,7 @@ ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask, REPLY_FIELD_CARD32(spec.mask); REPLY_FIELD_CARD32(length); // need to do it, since not calling REPLY_SEND() - if (sendClient->swapped) swapl (value); + REPLY_BUF_CARD32(value, 1); memcpy(ptr, &rep, sizeof(rep)); *value = pid; diff --git a/dbe/dbe.c b/dbe/dbe.c index 31134b0ee7..b4d70022b6 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -121,23 +121,13 @@ ProcDbeGetVersion(ClientPtr client) REQUEST_HEAD_STRUCT(xDbeGetVersionReq); xDbeGetVersionReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0, .majorVersion = DBE_MAJOR_VERSION, .minorVersion = DBE_MINOR_VERSION }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - } + REPLY_SEND_RET_SUCCESS(); +} - WriteToClient(client, sizeof(xDbeGetVersionReply), &rep); - - return Success; - -} /* ProcDbeGetVersion() */ - /****************************************************************************** * * DBE DIX Procedure: ProcDbeAllocateBackBufferName @@ -569,7 +559,6 @@ ProcDbeGetVisualInfo(ClientPtr client) REQUEST_REST_CARD32(); DbeScreenPrivPtr pDbeScreenPriv; - xDbeGetVisualInfoReply rep; register int i, j, rc; register int count; /* number of visual infos in reply */ register int length; /* length of reply */ @@ -627,22 +616,6 @@ ProcDbeGetVisualInfo(ClientPtr client) length += pScrVisInfo[i].count * sizeof(xDbeVisInfo); } - rep = (xDbeGetVisualInfoReply) { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = bytes_to_int32(length), - .m = count - }; - - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.m); - } - - /* Send off reply. */ - WriteToClient(client, sizeof(xDbeGetVisualInfoReply), &rep); - { char buf[length]; char *walk = buf; @@ -652,7 +625,7 @@ ProcDbeGetVisualInfo(ClientPtr client) /* Send off number of visuals. */ *(CARD32*)walk = pScrVisInfo[i].count; - if (client->swapped) { swapl((CARD32*)walk); } + REPLY_BUF_CARD32((CARD32*)walk, 1); walk += sizeof(CARD32); /* Now send off visual info items. */ @@ -663,21 +636,20 @@ ProcDbeGetVisualInfo(ClientPtr client) * data structure. We will send data to the client from the * protocol data structure. */ - visInfo->visualID = pScrVisInfo[i].visinfo[j].visual; visInfo->depth = pScrVisInfo[i].visinfo[j].depth; visInfo->perfLevel = pScrVisInfo[i].visinfo[j].perflevel; - if (client->swapped) { - swapl(&visInfo->visualID); - - /* We do not need to swap depth and perfLevel since they are - * already 1 byte quantities. - */ - } + walk += sizeof(xDbeVisInfo); } } - WriteToClient(client, sizeof(buf), buf); + + xDbeGetVisualInfoReply rep = { + .m = count + }; + + REPLY_FIELD_CARD32(m); + REPLY_SEND_EXTRA(buf, length); } rc = Success; @@ -713,35 +685,21 @@ ProcDbeGetBackBufferAttributes(ClientPtr client) REQUEST_HEAD_STRUCT(xDbeGetBackBufferAttributesReq); REQUEST_FIELD_CARD32(buffer); - xDbeGetBackBufferAttributesReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = 0 - }; DbeWindowPrivPtr pDbeWindowPriv; int rc; rc = dixLookupResourceByType((void **) &pDbeWindowPriv, stuff->buffer, dbeWindowPrivResType, client, DixGetAttrAccess); - if (rc == Success) { - rep.attributes = pDbeWindowPriv->pWindow->drawable.id; - } - else { - rep.attributes = None; - } - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.attributes); - } + xDbeGetBackBufferAttributesReply rep = { + .attributes = (rc == Success) ? pDbeWindowPriv->pWindow->drawable.id : None, + }; - WriteToClient(client, sizeof(xDbeGetBackBufferAttributesReply), &rep); - return Success; + REPLY_FIELD_CARD32(attributes); + REPLY_SEND_RET_SUCCESS(); +} -} /* ProcDbeGetbackBufferAttributes() */ - /****************************************************************************** * * DBE DIX Procedure: ProcDbeDispatch