From bbfdb50b5c212d4d007e029bfb11f6585cb41191 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 ec0354c38..d05c652be 100644 --- a/Xext/xres.c +++ b/Xext/xres.c @@ -430,7 +430,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 1dd817c22..7c9740553 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -115,23 +115,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 @@ -563,7 +553,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 */ @@ -621,22 +610,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; @@ -646,7 +619,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. */ @@ -657,21 +630,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; @@ -707,35 +679,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