Xext: xv: ProcXvQueryEncodings(): use payload length from rpcbuf

Skip the extra payload size calculation, use the rpcbuf's wpos instead.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-07-17 20:56:54 +02:00
committed by Enrico Weigelt
parent 90a99141b5
commit 75f2b2334d

View File

@@ -183,7 +183,6 @@ ProcXvQueryAdaptors(ClientPtr client)
static int
ProcXvQueryEncodings(ClientPtr client)
{
int totalSize;
XvPortPtr pPort;
int ne;
XvEncodingPtr pe;
@@ -193,29 +192,6 @@ ProcXvQueryEncodings(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
/* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
ne = pPort->pAdaptor->nEncodings;
pe = pPort->pAdaptor->pEncodings;
totalSize = ne * sz_xvEncodingInfo;
while (ne--) {
totalSize += pad_to_int32(strlen(pe->name));
pe++;
}
xvQueryEncodingsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_encodings = pPort->pAdaptor->nEncodings,
.length = bytes_to_int32(totalSize),
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.num_encodings);
}
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
ne = pPort->pAdaptor->nEncodings;
@@ -237,6 +213,19 @@ ProcXvQueryEncodings(ClientPtr client)
if (rpcbuf.error)
return BadAlloc;
xvQueryEncodingsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_encodings = pPort->pAdaptor->nEncodings,
.length = bytes_to_int32(rpcbuf.wpos),
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.num_encodings);
}
WriteToClient(client, sizeof(rep), &rep);
WriteRpcbufToClient(client, &rpcbuf);
return Success;