(submit/glx-cleanups-vla) glx: assign at declaration

Assigning structs at declaration is quicker to read/understand. No need
to support ancient compilers that couldn't do that, anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-08-28 13:25:06 +02:00
parent 64cdc862cd
commit 7234be2143
4 changed files with 32 additions and 38 deletions

View File

@ -704,14 +704,13 @@ __glXDisp_IsDirect(__GLXclientState * cl, GLbyte * pc)
{
ClientPtr client = cl->client;
xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
xGLXIsDirectReply reply;
__GLXcontext *glxc;
int err;
if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err))
return err;
reply = (xGLXIsDirectReply) {
xGLXIsDirectReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
@ -733,13 +732,11 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc)
{
ClientPtr client = cl->client;
xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc;
xGLXQueryVersionReply reply;
GLuint major, minor;
REQUEST_SIZE_MATCH(xGLXQueryVersionReq);
major = req->majorVersion;
minor = req->minorVersion;
GLuint major = req->majorVersion;
GLuint minor = req->minorVersion;
(void) major;
(void) minor;
@ -748,7 +745,7 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc)
** client if it wants to work with older clients; however, in this
** implementation the server just returns its version number.
*/
reply = (xGLXQueryVersionReply) {
xGLXQueryVersionReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
@ -908,7 +905,6 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
{
xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
ClientPtr client = cl->client;
xGLXGetVisualConfigsReply reply;
__GLXscreen *pGlxScreen;
__GLXconfig *modes;
CARD32 buf[GLX_VIS_CONFIG_TOTAL];
@ -920,7 +916,7 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
return err;
reply = (xGLXGetVisualConfigsReply) {
xGLXGetVisualConfigsReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = (pGlxScreen->numVisuals *
@ -1023,7 +1019,6 @@ static int
DoGetFBConfigs(__GLXclientState * cl, unsigned screen)
{
ClientPtr client = cl->client;
xGLXGetFBConfigsReply reply;
__GLXscreen *pGlxScreen;
CARD32 buf[__GLX_FBCONFIG_ATTRIBS_LENGTH];
int p, err;
@ -1035,7 +1030,7 @@ DoGetFBConfigs(__GLXclientState * cl, unsigned screen)
if (!validGlxScreen(cl->client, screen, &pGlxScreen, &err))
return err;
reply = (xGLXGetFBConfigsReply) {
xGLXGetFBConfigsReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = __GLX_FBCONFIG_ATTRIBS_LENGTH * pGlxScreen->numFBConfigs,
@ -1664,7 +1659,6 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId)
{
ClientPtr client = cl->client;
__GLXcontext *ctx;
xGLXQueryContextInfoEXTReply reply;
int nProps = 5;
int sendBuf[nProps * 2];
int nReplyBytes;
@ -1673,7 +1667,7 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId)
if (!validGlxContext(cl->client, gcId, DixReadAccess, &ctx, &err))
return err;
reply = (xGLXQueryContextInfoEXTReply) {
xGLXQueryContextInfoEXTReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = nProps << 1,
@ -1879,7 +1873,6 @@ static int
DoGetDrawableAttributes(__GLXclientState * cl, XID drawId)
{
ClientPtr client = cl->client;
xGLXGetDrawableAttributesReply reply;
__GLXdrawable *pGlxDraw = NULL;
DrawablePtr pDraw;
CARD32 attributes[20];
@ -1929,7 +1922,7 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId)
ATTRIB(GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT);
#undef ATTRIB
reply = (xGLXGetDrawableAttributesReply) {
xGLXGetDrawableAttributesReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = num << 1,
@ -2375,7 +2368,6 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
{
ClientPtr client = cl->client;
xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc;
xGLXQueryExtensionsStringReply reply;
__GLXscreen *pGlxScreen;
size_t n, length;
char *buf;
@ -2386,7 +2378,8 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
n = strlen(pGlxScreen->GLXextensions) + 1;
length = __GLX_PAD(n) >> 2;
reply = (xGLXQueryExtensionsStringReply) {
xGLXQueryExtensionsStringReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = length,
@ -2427,7 +2420,6 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc)
{
ClientPtr client = cl->client;
xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) pc;
xGLXQueryServerStringReply reply;
size_t n, length;
const char *ptr;
char *buf;
@ -2459,7 +2451,8 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc)
n = strlen(ptr) + 1;
length = __GLX_PAD(n) >> 2;
reply = (xGLXQueryServerStringReply) {
xGLXQueryServerStringReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = length,

View File

@ -115,7 +115,6 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements,
size_t element_size, GLboolean always_array, CARD32 retval)
{
size_t reply_ints = 0;
xGLXSingleReply reply = { 0, };
if (__glXErrorOccured()) {
elements = 0;
@ -124,11 +123,13 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements,
reply_ints = bytes_to_int32(elements * element_size);
}
reply.length = reply_ints;
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
reply.size = elements;
reply.retval = retval;
xGLXSingleReply reply = {
.length = reply_ints,
.type = X_Reply,
.sequenceNumber = client->sequence,
.size = elements,
.retval = retval,
};
/* It is faster on almost always every architecture to just copy the 8
* bytes, even when not necessary, than check to see of the value of
@ -162,7 +163,6 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements,
size_t element_size, GLboolean always_array, CARD32 retval)
{
size_t reply_ints = 0;
xGLXSingleReply reply = { 0, };
if (__glXErrorOccured()) {
elements = 0;
@ -171,11 +171,13 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements,
reply_ints = bytes_to_int32(elements * element_size);
}
reply.length = bswap_32(reply_ints);
reply.type = X_Reply;
reply.sequenceNumber = bswap_16(client->sequence);
reply.size = bswap_32(elements);
reply.retval = bswap_32(retval);
xGLXSingleReply reply = {
.length = bswap_32(reply_ints),
.type = X_Reply,
.sequenceNumber = bswap_16(client->sequence),
.size = bswap_32(elements),
.retval = bswap_32(retval),
};
/* It is faster on almost always every architecture to just copy the 8
* bytes, even when not necessary, than check to see of the value of

View File

@ -108,7 +108,6 @@ int
__glXDisp_RenderMode(__GLXclientState * cl, GLbyte * pc)
{
ClientPtr client = cl->client;
xGLXRenderModeReply reply;
__GLXcontext *cx;
GLint nitems = 0, retBytes = 0, retval, newModeCheck;
GLubyte *retBuffer = NULL;
@ -193,7 +192,7 @@ __glXDisp_RenderMode(__GLXclientState * cl, GLbyte * pc)
** selection array, as per the API for glRenderMode itself.
*/
noChangeAllowed:;
reply = (xGLXRenderModeReply) {
xGLXRenderModeReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = nitems,
@ -232,7 +231,6 @@ __glXDisp_Finish(__GLXclientState * cl, GLbyte * pc)
ClientPtr client = cl->client;
__GLXcontext *cx;
int error;
xGLXSingleReply reply = { 0, };
REQUEST_SIZE_MATCH(xGLXSingleReq);
@ -246,6 +244,8 @@ __glXDisp_Finish(__GLXclientState * cl, GLbyte * pc)
/* Send empty reply packet to indicate finish is finished */
client = cl->client;
xGLXSingleReply reply = { 0 };
__GLX_BEGIN_REPLY(0);
__GLX_SEND_HEADER();
return Success;
@ -329,7 +329,6 @@ DoGetString(__GLXclientState * cl, GLbyte * pc, GLboolean need_swap)
__GLXcontext *cx;
GLenum name;
const char *string;
xGLXSingleReply reply = { 0, };
__GLX_DECLARE_SWAP_VARIABLES;
int error;
@ -383,6 +382,7 @@ DoGetString(__GLXclientState * cl, GLbyte * pc, GLboolean need_swap)
length = strlen((const char *) string) + 1;
}
xGLXSingleReply reply = { 0 };
__GLX_BEGIN_REPLY(length);
__GLX_PUT_SIZE(length);

View File

@ -114,7 +114,6 @@ __glXDispSwap_RenderMode(__GLXclientState * cl, GLbyte * pc)
{
ClientPtr client = cl->client;
__GLXcontext *cx;
xGLXRenderModeReply reply;
GLint nitems = 0, retBytes = 0, retval, newModeCheck;
GLubyte *retBuffer = NULL;
GLenum newMode;
@ -205,7 +204,7 @@ __glXDispSwap_RenderMode(__GLXclientState * cl, GLbyte * pc)
** selection array, as per the API for glRenderMode itself.
*/
noChangeAllowed:;
reply = (xGLXRenderModeReply) {
xGLXRenderModeReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = nitems,
@ -252,7 +251,6 @@ __glXDispSwap_Finish(__GLXclientState * cl, GLbyte * pc)
ClientPtr client = cl->client;
__GLXcontext *cx;
int error;
xGLXSingleReply reply = { 0, };
__GLX_DECLARE_SWAP_VARIABLES;
@ -268,6 +266,7 @@ __glXDispSwap_Finish(__GLXclientState * cl, GLbyte * pc)
glFinish();
/* Send empty reply packet to indicate finish is finished */
xGLXSingleReply reply = { 0 };
__GLX_BEGIN_REPLY(0);
__GLX_PUT_RETVAL(0);
__GLX_SWAP_REPLY_HEADER();