randr: use X_SEND_REPLY_WITH_RPCBUF() macro

Use the new X_SEND_REPLY_WITH_RPCBUF() macro for final reply write out

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-08-14 20:20:02 +02:00
committed by Enrico Weigelt
parent 5842bd9c86
commit 1d93fbc68e
5 changed files with 19 additions and 79 deletions

View File

@@ -1163,9 +1163,7 @@ ProcRRGetCrtcInfo(ClientPtr client)
RRModePtr mode = crtc->mode;
xRRGetCrtcInfoReply rep = {
.type = X_Reply,
.status = RRSetConfigSuccess,
.sequenceNumber = client->sequence,
.timestamp = pScrPriv->lastSetTime.milliseconds,
.rotation = crtc->rotation,
.rotations = crtc->rotations,
@@ -1219,8 +1217,6 @@ ProcRRGetCrtcInfo(ClientPtr client)
}
}
rep.length = x_rpcbuf_wsize_units(&rpcbuf);
if (rpcbuf.error)
return BadAlloc;
@@ -1228,8 +1224,6 @@ ProcRRGetCrtcInfo(ClientPtr client)
pScrPriv->rrCrtcGet(pScreen, crtc, &rep);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.timestamp);
swaps(&rep.x);
swaps(&rep.y);
@@ -1242,8 +1236,7 @@ ProcRRGetCrtcInfo(ClientPtr client)
swaps(&rep.nPossibleOutput);
}
WriteToClient(client, sizeof(xRRGetCrtcInfoReply), &rep);
WriteRpcbufToClient(client, &rpcbuf);
X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
return Success;
}
@@ -1646,19 +1639,14 @@ ProcRRGetCrtcGamma(ClientPtr client)
x_rpcbuf_write_CARD16s(&rpcbuf, crtc->gammaBlue, crtc->gammaSize);
xRRGetCrtcGammaReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = x_rpcbuf_wsize_units(&rpcbuf),
.size = crtc->gammaSize
};
if (client->swapped) {
swaps(&reply.sequenceNumber);
swapl(&reply.length);
swaps(&reply.size);
}
WriteToClient(client, sizeof(xRRGetCrtcGammaReply), &reply);
WriteRpcbufToClient(client, &rpcbuf);
X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
return Success;
}
@@ -1744,8 +1732,6 @@ ProcRRGetCrtcTransform(ClientPtr client)
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
xRRGetCrtcTransformReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.hasTransforms = crtc->transforms,
};
@@ -1769,12 +1755,7 @@ ProcRRGetCrtcTransform(ClientPtr client)
if (rpcbuf.error)
return BadAlloc;
rep.length = bytes_to_int32(sizeof(xRRGetCrtcTransformReply) - sizeof(xGenericReply)
+ rpcbuf.wpos);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
SwapLongs((CARD32 *) &rep.pendingTransform, bytes_to_int32(sizeof(xRenderTransform)));
SwapLongs((CARD32 *) &rep.currentTransform, bytes_to_int32(sizeof(xRenderTransform)));
swaps(&rep.pendingNbytesFilter);
@@ -1783,8 +1764,7 @@ ProcRRGetCrtcTransform(ClientPtr client)
swaps(&rep.currentNparamsFilter);
}
WriteToClient(client, sizeof(xRRGetCrtcTransformReply), &rep);
WriteRpcbufToClient(client, &rpcbuf);
X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
return Success;
}

View File

@@ -636,24 +636,18 @@ ProcRRGetMonitors(ClientPtr client)
RRMonitorFreeList(monitors, nmonitors);
xRRGetMonitorsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.timestamp = RRMonitorTimestamp(screen),
.nmonitors = nmonitors,
.noutputs = noutputs,
.length = x_rpcbuf_wsize_units(&rpcbuf),
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.timestamp);
swapl(&rep.nmonitors);
swapl(&rep.noutputs);
}
WriteToClient(client, sizeof(xRRGetMonitorsReply), &rep);
WriteRpcbufToClient(client, &rpcbuf);
X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
return Success;
}

View File

@@ -460,10 +460,7 @@ ProcRRGetOutputInfo(ClientPtr client)
pScrPriv = rrGetScrPriv(pScreen);
xRRGetOutputInfoReply rep = {
.type = X_Reply,
.status = RRSetConfigSuccess,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(sizeof(xRRGetOutputInfoReply)-sizeof(xReply)),
.timestamp = pScrPriv->lastSetTime.milliseconds,
.nameLength = output->nameLength,
};
@@ -500,11 +497,7 @@ ProcRRGetOutputInfo(ClientPtr client)
x_rpcbuf_write_string_pad(&rpcbuf, output->name); /* indeed 0-terminated */
rep.length += x_rpcbuf_wsize_units(&rpcbuf);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.timestamp);
swapl(&rep.crtc);
swapl(&rep.mmWidth);
@@ -516,8 +509,7 @@ ProcRRGetOutputInfo(ClientPtr client)
swaps(&rep.nameLength);
}
WriteToClient(client, sizeof(xRRGetOutputInfoReply), &rep);
WriteRpcbufToClient(client, &rpcbuf);
X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
return Success;
}

View File

@@ -434,20 +434,14 @@ ProcRRListOutputProperties(ClientPtr client)
return BadAlloc;
xRRListOutputPropertiesReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = x_rpcbuf_wsize_units(&rpcbuf),
.nAtoms = numProps
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.nAtoms);
}
WriteToClient(client, sizeof(xRRListOutputPropertiesReply), &rep);
WriteRpcbufToClient(client, &rpcbuf);
X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
return Success;
}
@@ -472,21 +466,12 @@ ProcRRQueryOutputProperty(ClientPtr client)
return BadAlloc;
xRRQueryOutputPropertyReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = x_rpcbuf_wsize_units(&rpcbuf),
.pending = prop->is_pending,
.range = prop->range,
.immutable = prop->immutable
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xRRQueryOutputPropertyReply), &rep);
WriteRpcbufToClient(client, &rpcbuf);
X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
return Success;
}

View File

@@ -531,10 +531,6 @@ ProcRRGetProviderProperty(ClientPtr client)
RRPropertyValuePtr prop_value;
unsigned long n, len, ind;
RRProviderPtr provider;
xRRGetProviderPropertyReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence
};
REQUEST_SIZE_MATCH(xRRGetProviderPropertyReq);
if (stuff->delete)
@@ -559,13 +555,12 @@ ProcRRGetProviderProperty(ClientPtr client)
if (prop->propertyName == stuff->property)
break;
if (!prop) {
if (client->swapped) {
swaps(&reply.sequenceNumber);
}
WriteToClient(client, sizeof(xRRGetProviderPropertyReply), &reply);
return Success;
}
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
xRRGetProviderPropertyReply reply = { 0 };
if (!prop)
goto sendout;
if (prop->immutable && stuff->delete)
return BadAccess;
@@ -583,12 +578,11 @@ ProcRRGetProviderProperty(ClientPtr client)
reply.format = prop_value->format;
reply.propertyType = prop_value->type;
if (client->swapped) {
swaps(&reply.sequenceNumber);
swapl(&reply.propertyType);
swapl(&reply.bytesAfter);
}
WriteToClient(client, sizeof(xRRGetProviderPropertyReply), &reply);
return Success;
goto sendout;
}
/*
@@ -609,7 +603,6 @@ ProcRRGetProviderProperty(ClientPtr client)
reply.bytesAfter = n - (ind + len);
reply.format = prop_value->format;
reply.length = bytes_to_int32(len);
if (prop_value->format)
reply.nItems = len / (prop_value->format / 8);
reply.propertyType = prop_value->type;
@@ -627,15 +620,11 @@ ProcRRGetProviderProperty(ClientPtr client)
}
if (client->swapped) {
swaps(&reply.sequenceNumber);
swapl(&reply.length);
swapl(&reply.propertyType);
swapl(&reply.bytesAfter);
swapl(&reply.nItems);
}
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
if (len) {
const char *dataptr = ((char*)prop_value->data) + ind;
switch (prop_value->format) {
@@ -654,12 +643,12 @@ ProcRRGetProviderProperty(ClientPtr client)
if (rpcbuf.error)
return BadAlloc;
WriteToClient(client, sizeof(reply), &reply);
WriteRpcbufToClient(client, &rpcbuf);
if (stuff->delete && (reply.bytesAfter == 0)) { /* delete the Property */
*prev = prop->next;
RRDestroyProviderProperty(prop);
}
sendout:
X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
return Success;
}