xkb: ProcXkbGetMap(): use X_SEND_REPLY_WITH_RPCBUF()

Use generic macro for sending out final reply.
Also dropping our own unnecessary size payload computation - rpcbuf
already giving us this value.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-08-19 12:32:12 +02:00
committed by Enrico Weigelt
parent 7f648df8af
commit b8a30d7347

View File

@@ -1405,10 +1405,7 @@ ProcXkbGetMap(ClientPtr client)
xkb = dev->key->xkbInfo->desc;
xkbGetMapReply rep = {
.type = X_Reply,
.deviceID = dev->id,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(sizeof(xkbGetMapReply) - sizeof(xGenericReply)),
.present = stuff->partial | stuff->full,
.minKeyCode = xkb->min_key_code,
.maxKeyCode = xkb->max_key_code,
@@ -1497,22 +1494,10 @@ ProcXkbGetMap(ClientPtr client)
if ((status = XkbComputeGetMapReplySize(xkb, &rep)) != Success)
return status;
int payload_len = (rep.length * sizeof(CARD32)) - (sizeof(xkbGetMapReply) - sizeof(xGenericReply));
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
if (!x_rpcbuf_makeroom(&rpcbuf, payload_len))
return BadAlloc;
/* use rpcbuf.wpos here, in order to get how much we've really written */
if (rpcbuf.wpos != payload_len)
LogMessage(X_WARNING, "ProcXkbGetMap() payload_len mismatch: %ld but shoud be %d\n",
rpcbuf.wpos, payload_len);
XkbAssembleMap(client, xkb, rep, &rpcbuf);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.present);
swaps(&rep.totalSyms);
swaps(&rep.totalActs);
@@ -1521,8 +1506,7 @@ ProcXkbGetMap(ClientPtr client)
if (rpcbuf.error)
return BadAlloc;
WriteToClient(client, sizeof(xkbGetMapReply), &rep);
WriteRpcbufToClient(client, &rpcbuf);
X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
return Success;
}