dbe: ProcDbeGetVisualInfo(): drop unncessary payload length computation

Since using x_rpcbuf, we don't need extra computation of the payload_length,
as the x_rpcbuf already knows the amount of data written into it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-07-15 20:34:13 +02:00
committed by Enrico Weigelt
parent b60c739384
commit 1bcff3fe35

View File

@@ -561,12 +561,10 @@ ProcDbeGetVisualInfo(ClientPtr client)
{
REQUEST(xDbeGetVisualInfoReq);
DbeScreenPrivPtr pDbeScreenPriv;
xDbeGetVisualInfoReply rep;
Drawable *drawables;
DrawablePtr *pDrawables = NULL;
register int i, rc;
register int count; /* number of visual infos in reply */
register int length; /* length of reply */
ScreenPtr pScreen;
XdbeScreenVisualInfo *pScrVisInfo;
@@ -605,8 +603,6 @@ ProcDbeGetVisualInfo(ClientPtr client)
return BadAlloc;
}
length = 0;
for (i = 0; i < count; i++) {
pScreen = (stuff->n == 0) ? screenInfo.screens[i] :
pDrawables[i]->pScreen;
@@ -623,25 +619,6 @@ ProcDbeGetVisualInfo(ClientPtr client)
/* Free visinfos that we allocated for previous screen infos. */
goto clearRpcBuf;
}
/* Account for n, number of xDbeVisInfo items in list. */
length += sizeof(CARD32);
/* Account for n xDbeVisInfo items */
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);
}
for (i = 0; i < count; i++) {
@@ -666,6 +643,24 @@ ProcDbeGetVisualInfo(ClientPtr client)
}
}
if (rpcbuf.error) {
rc = BadAlloc;
goto clearRpcBuf;
}
xDbeGetVisualInfoReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(rpcbuf.wpos),
.m = count
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.m);
}
rc = Success;
WriteToClient(client, sizeof(xDbeGetVisualInfoReply), &rep);
WriteRpcbufToClient(client, &rpcbuf);