(submit/cleanup-xv-dispatch) Xext: xv: use static struct initialization on declaration

A little bit of code simplification by using static initialization
of struct right at the point of declaration. Also dropping a few now
unneccessary zero assignments.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-08 18:47:45 +02:00
parent fc82a71e35
commit 3ab8f10b65

View File

@ -323,7 +323,6 @@ ProcXvQueryAdaptors(ClientPtr client)
{ {
xvFormat format; xvFormat format;
xvAdaptorInfo ainfo; xvAdaptorInfo ainfo;
xvQueryAdaptorsReply rep;
int totalSize, na, nf, rc; int totalSize, na, nf, rc;
int nameSize; int nameSize;
XvAdaptorPtr pa; XvAdaptorPtr pa;
@ -339,27 +338,20 @@ ProcXvQueryAdaptors(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
xvQueryAdaptorsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
};
pScreen = pWin->drawable.pScreen; pScreen = pWin->drawable.pScreen;
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
XvGetScreenKey()); XvGetScreenKey());
if (!pxvs) { if (!pxvs) {
rep = (xvQueryAdaptorsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.num_adaptors = 0
};
_WriteQueryAdaptorsReply(client, &rep); _WriteQueryAdaptorsReply(client, &rep);
return Success; return Success;
} }
rep = (xvQueryAdaptorsReply) { rep.num_adaptors = pxvs->nAdaptors;
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_adaptors = pxvs->nAdaptors
};
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */ /* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
@ -413,7 +405,6 @@ static int
ProcXvQueryEncodings(ClientPtr client) ProcXvQueryEncodings(ClientPtr client)
{ {
xvEncodingInfo einfo; xvEncodingInfo einfo;
xvQueryEncodingsReply rep;
int totalSize; int totalSize;
int nameSize; int nameSize;
XvPortPtr pPort; XvPortPtr pPort;
@ -425,12 +416,6 @@ ProcXvQueryEncodings(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
rep = (xvQueryEncodingsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_encodings = pPort->pAdaptor->nEncodings
};
/* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */ /* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
ne = pPort->pAdaptor->nEncodings; ne = pPort->pAdaptor->nEncodings;
@ -441,7 +426,12 @@ ProcXvQueryEncodings(ClientPtr client)
pe++; pe++;
} }
rep.length = bytes_to_int32(totalSize); xvQueryEncodingsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_encodings = pPort->pAdaptor->nEncodings,
.length = bytes_to_int32(totalSize),
};
_WriteQueryEncodingsReply(client, &rep); _WriteQueryEncodingsReply(client, &rep);
@ -617,7 +607,6 @@ ProcXvGrabPort(ClientPtr client)
{ {
int result, status; int result, status;
XvPortPtr pPort; XvPortPtr pPort;
xvGrabPortReply rep;
REQUEST(xvGrabPortReq); REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq); REQUEST_SIZE_MATCH(xvGrabPortReq);
@ -629,10 +618,9 @@ ProcXvGrabPort(ClientPtr client)
if (status != Success) { if (status != Success) {
return status; return status;
} }
rep = (xvGrabPortReply) { xvGrabPortReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.result = result .result = result
}; };
@ -706,7 +694,6 @@ ProcXvGetPortAttribute(ClientPtr client)
INT32 value; INT32 value;
int status; int status;
XvPortPtr pPort; XvPortPtr pPort;
xvGetPortAttributeReply rep;
REQUEST(xvGetPortAttributeReq); REQUEST(xvGetPortAttributeReq);
REQUEST_SIZE_MATCH(xvGetPortAttributeReq); REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
@ -724,10 +711,9 @@ ProcXvGetPortAttribute(ClientPtr client)
return status; return status;
} }
rep = (xvGetPortAttributeReply) { xvGetPortAttributeReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.value = value .value = value
}; };
@ -741,7 +727,6 @@ ProcXvQueryBestSize(ClientPtr client)
{ {
unsigned int actual_width, actual_height; unsigned int actual_width, actual_height;
XvPortPtr pPort; XvPortPtr pPort;
xvQueryBestSizeReply rep;
REQUEST(xvQueryBestSizeReq); REQUEST(xvQueryBestSizeReq);
REQUEST_SIZE_MATCH(xvQueryBestSizeReq); REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
@ -753,10 +738,9 @@ ProcXvQueryBestSize(ClientPtr client)
stuff->drw_w, stuff->drw_h, stuff->drw_w, stuff->drw_h,
&actual_width, &actual_height); &actual_width, &actual_height);
rep = (xvQueryBestSizeReply) { xvQueryBestSizeReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.actual_width = actual_width, .actual_width = actual_width,
.actual_height = actual_height .actual_height = actual_height
}; };
@ -772,7 +756,6 @@ ProcXvQueryPortAttributes(ClientPtr client)
int size, i; int size, i;
XvPortPtr pPort; XvPortPtr pPort;
XvAttributePtr pAtt; XvAttributePtr pAtt;
xvQueryPortAttributesReply rep;
xvAttributeInfo Info; xvAttributeInfo Info;
REQUEST(xvQueryPortAttributesReq); REQUEST(xvQueryPortAttributesReq);
@ -780,11 +763,10 @@ ProcXvQueryPortAttributes(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
rep = (xvQueryPortAttributesReply) { xvQueryPortAttributesReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.num_attributes = pPort->pAdaptor->nAttributes, .num_attributes = pPort->pAdaptor->nAttributes,
.text_size = 0
}; };
for (i = 0, pAtt = pPort->pAdaptor->pAttributes; for (i = 0, pAtt = pPort->pAdaptor->pAttributes;
@ -1031,7 +1013,6 @@ ProcXvListImageFormats(ClientPtr client)
XvPortPtr pPort; XvPortPtr pPort;
XvImagePtr pImage; XvImagePtr pImage;
int i; int i;
xvListImageFormatsReply rep;
xvImageFormatInfo info; xvImageFormatInfo info;
REQUEST(xvListImageFormatsReq); REQUEST(xvListImageFormatsReq);
@ -1040,7 +1021,7 @@ ProcXvListImageFormats(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
rep = (xvListImageFormatsReply) { xvListImageFormatsReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.num_formats = pPort->pAdaptor->nImages, .num_formats = pPort->pAdaptor->nImages,