treewide: macro for computing extra units needed for reply header

Add and use macro X_REPLY_HEADER_UNITS() for computing how many
extra protocol units are needed for a reply header (for .length field)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-08-14 16:40:42 +02:00
committed by Enrico Weigelt
parent bb6a70be0f
commit d6089c52c3
7 changed files with 23 additions and 37 deletions

View File

@@ -256,8 +256,7 @@ ProcVidModeGetModeLine(ClientPtr client)
.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS),
.length = bytes_to_int32(sizeof(xXF86VidModeGetModeLineReply) -
sizeof(xGenericReply)),
.length = X_REPLY_HEADER_UNITS(xXF86VidModeGetModeLineReply),
/*
* Older servers sometimes had server privates that the VidMode
* extension made available. So to be compatible pretend that
@@ -294,8 +293,7 @@ ProcVidModeGetModeLine(ClientPtr client)
xXF86OldVidModeGetModeLineReply oldrep = {
.type = rep.type,
.sequenceNumber = rep.sequenceNumber,
.length = bytes_to_int32(sizeof(xXF86OldVidModeGetModeLineReply) -
sizeof(xGenericReply)),
.length = X_REPLY_HEADER_UNITS(xXF86OldVidModeGetModeLineReply),
.dotclock = rep.dotclock,
.hdisplay = rep.hdisplay,
.hsyncstart = rep.hsyncstart,
@@ -395,8 +393,8 @@ ProcVidModeGetAllModeLines(ClientPtr client)
xXF86VidModeGetAllModeLinesReply rep = {
.type = X_Reply,
.length = bytes_to_int32(sizeof(xXF86VidModeGetAllModeLinesReply) -
sizeof(xGenericReply) + rpcbuf.wpos),
.length = X_REPLY_HEADER_UNITS(xXF86VidModeGetAllModeLinesReply)
+ x_rpcbuf_wsize_units(&rpcbuf),
.sequenceNumber = client->sequence,
.modecount = modecount
};
@@ -1009,8 +1007,7 @@ VidModeValidateModeLine(ClientPtr client, xXF86VidModeValidateModeLineReq *stuff
xXF86VidModeValidateModeLineReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(sizeof(xXF86VidModeValidateModeLineReply)
- sizeof(xGenericReply)),
.length = X_REPLY_HEADER_UNITS(xXF86VidModeValidateModeLineReply),
.status = status
};
if (client->swapped) {
@@ -1258,8 +1255,7 @@ ProcVidModeGetMonitor(ClientPtr client)
.nvsync = nVrefresh,
.vendorLength = x_safe_strlen(vendorStr),
.modelLength = x_safe_strlen(modelStr),
.length = bytes_to_int32(sizeof(xXF86VidModeGetMonitorReply) -
sizeof(xGenericReply)) +
.length = X_REPLY_HEADER_UNITS(xXF86VidModeGetMonitorReply) +
x_rpcbuf_wsize_units(&rpcbuf)
};
@@ -1387,8 +1383,7 @@ ProcVidModeGetDotClocks(ClientPtr client)
xXF86VidModeGetDotClocksReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(sizeof(xXF86VidModeGetDotClocksReply)
- sizeof(xGenericReply)) + numClocks,
.length = X_REPLY_HEADER_UNITS(xXF86VidModeGetDotClocksReply) + numClocks,
.clocks = numClocks,
.maxclocks = MAXCLOCKS,
.flags = (ClockProg ? CLKFLAG_PROGRAMABLE : 0),