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

@@ -980,8 +980,8 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
}
reply->type = X_Reply;
reply->length =
bytes_to_int32(sizeof *reply - sizeof(xGenericReply) +
pFontInfo->nprops * sizeof(xFontProp) + namelen);
X_REPLY_HEADER_UNITS(xListFontsWithInfoReply)
+ bytes_to_int32(pFontInfo->nprops*sizeof(xFontProp)+namelen);
reply->sequenceNumber = client->sequence;
reply->nameLength = namelen;
reply->minBounds = pFontInfo->ink_minbounds;
@@ -1020,8 +1020,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
xListFontsWithInfoReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(sizeof(xListFontsWithInfoReply)
- sizeof(xGenericReply))
.length = X_REPLY_HEADER_UNITS(xListFontsWithInfoReply)
};
if (client->swapped) {
SwapFont((xQueryFontReply *) &rep, FALSE);

View File

@@ -1578,8 +1578,7 @@ ProcGetWindowAttributes(ClientPtr client)
.bitGravity = pWin->bitGravity,
.winGravity = pWin->winGravity,
.backingStore = pWin->backingStore,
.length = bytes_to_int32(sizeof(xGetWindowAttributesReply) -
sizeof(xGenericReply)),
.length = X_REPLY_HEADER_UNITS(xGetWindowAttributesReply),
.sequenceNumber = client->sequence,
.backingBitPlanes = wBackingBitPlanes(pWin),
.backingPixel = wBackingPixel(pWin),