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> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1665>
This commit is contained in:
parent
161c3c8398
commit
558ded4dbf
|
@ -702,14 +702,13 @@ __glXDisp_IsDirect(__GLXclientState * cl, GLbyte * pc)
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
|
xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
|
||||||
xGLXIsDirectReply reply;
|
|
||||||
__GLXcontext *glxc;
|
__GLXcontext *glxc;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err))
|
if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err))
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
reply = (xGLXIsDirectReply) {
|
xGLXIsDirectReply reply = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = 0,
|
.length = 0,
|
||||||
|
@ -731,13 +730,11 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc)
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc;
|
xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc;
|
||||||
xGLXQueryVersionReply reply;
|
|
||||||
GLuint major, minor;
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xGLXQueryVersionReq);
|
REQUEST_SIZE_MATCH(xGLXQueryVersionReq);
|
||||||
|
|
||||||
major = req->majorVersion;
|
GLuint major = req->majorVersion;
|
||||||
minor = req->minorVersion;
|
GLuint minor = req->minorVersion;
|
||||||
(void) major;
|
(void) major;
|
||||||
(void) minor;
|
(void) minor;
|
||||||
|
|
||||||
|
@ -746,7 +743,7 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc)
|
||||||
** client if it wants to work with older clients; however, in this
|
** client if it wants to work with older clients; however, in this
|
||||||
** implementation the server just returns its version number.
|
** implementation the server just returns its version number.
|
||||||
*/
|
*/
|
||||||
reply = (xGLXQueryVersionReply) {
|
xGLXQueryVersionReply reply = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = 0,
|
.length = 0,
|
||||||
|
@ -906,7 +903,6 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
|
||||||
{
|
{
|
||||||
xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
|
xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
xGLXGetVisualConfigsReply reply;
|
|
||||||
__GLXscreen *pGlxScreen;
|
__GLXscreen *pGlxScreen;
|
||||||
__GLXconfig *modes;
|
__GLXconfig *modes;
|
||||||
CARD32 buf[GLX_VIS_CONFIG_TOTAL];
|
CARD32 buf[GLX_VIS_CONFIG_TOTAL];
|
||||||
|
@ -918,7 +914,7 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
|
||||||
if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
|
if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
reply = (xGLXGetVisualConfigsReply) {
|
xGLXGetVisualConfigsReply reply = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = (pGlxScreen->numVisuals *
|
.length = (pGlxScreen->numVisuals *
|
||||||
|
@ -1021,7 +1017,6 @@ static int
|
||||||
DoGetFBConfigs(__GLXclientState * cl, unsigned screen)
|
DoGetFBConfigs(__GLXclientState * cl, unsigned screen)
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
xGLXGetFBConfigsReply reply;
|
|
||||||
__GLXscreen *pGlxScreen;
|
__GLXscreen *pGlxScreen;
|
||||||
CARD32 buf[__GLX_FBCONFIG_ATTRIBS_LENGTH];
|
CARD32 buf[__GLX_FBCONFIG_ATTRIBS_LENGTH];
|
||||||
int p, err;
|
int p, err;
|
||||||
|
@ -1033,7 +1028,7 @@ DoGetFBConfigs(__GLXclientState * cl, unsigned screen)
|
||||||
if (!validGlxScreen(cl->client, screen, &pGlxScreen, &err))
|
if (!validGlxScreen(cl->client, screen, &pGlxScreen, &err))
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
reply = (xGLXGetFBConfigsReply) {
|
xGLXGetFBConfigsReply reply = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = __GLX_FBCONFIG_ATTRIBS_LENGTH * pGlxScreen->numFBConfigs,
|
.length = __GLX_FBCONFIG_ATTRIBS_LENGTH * pGlxScreen->numFBConfigs,
|
||||||
|
@ -1662,7 +1657,6 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId)
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
__GLXcontext *ctx;
|
__GLXcontext *ctx;
|
||||||
xGLXQueryContextInfoEXTReply reply;
|
|
||||||
int nProps = 5;
|
int nProps = 5;
|
||||||
int sendBuf[nProps * 2];
|
int sendBuf[nProps * 2];
|
||||||
int nReplyBytes;
|
int nReplyBytes;
|
||||||
|
@ -1671,7 +1665,7 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId)
|
||||||
if (!validGlxContext(cl->client, gcId, DixReadAccess, &ctx, &err))
|
if (!validGlxContext(cl->client, gcId, DixReadAccess, &ctx, &err))
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
reply = (xGLXQueryContextInfoEXTReply) {
|
xGLXQueryContextInfoEXTReply reply = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = nProps << 1,
|
.length = nProps << 1,
|
||||||
|
@ -1877,7 +1871,6 @@ static int
|
||||||
DoGetDrawableAttributes(__GLXclientState * cl, XID drawId)
|
DoGetDrawableAttributes(__GLXclientState * cl, XID drawId)
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
xGLXGetDrawableAttributesReply reply;
|
|
||||||
__GLXdrawable *pGlxDraw = NULL;
|
__GLXdrawable *pGlxDraw = NULL;
|
||||||
DrawablePtr pDraw;
|
DrawablePtr pDraw;
|
||||||
CARD32 attributes[20];
|
CARD32 attributes[20];
|
||||||
|
@ -1927,7 +1920,7 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId)
|
||||||
ATTRIB(GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT);
|
ATTRIB(GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT);
|
||||||
#undef ATTRIB
|
#undef ATTRIB
|
||||||
|
|
||||||
reply = (xGLXGetDrawableAttributesReply) {
|
xGLXGetDrawableAttributesReply reply = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = num << 1,
|
.length = num << 1,
|
||||||
|
@ -2373,7 +2366,6 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc;
|
xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc;
|
||||||
xGLXQueryExtensionsStringReply reply;
|
|
||||||
__GLXscreen *pGlxScreen;
|
__GLXscreen *pGlxScreen;
|
||||||
size_t n, length;
|
size_t n, length;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
@ -2384,7 +2376,8 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
|
||||||
|
|
||||||
n = strlen(pGlxScreen->GLXextensions) + 1;
|
n = strlen(pGlxScreen->GLXextensions) + 1;
|
||||||
length = __GLX_PAD(n) >> 2;
|
length = __GLX_PAD(n) >> 2;
|
||||||
reply = (xGLXQueryExtensionsStringReply) {
|
|
||||||
|
xGLXQueryExtensionsStringReply reply = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = length,
|
.length = length,
|
||||||
|
@ -2425,7 +2418,6 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc)
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) pc;
|
xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) pc;
|
||||||
xGLXQueryServerStringReply reply;
|
|
||||||
size_t n, length;
|
size_t n, length;
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
@ -2457,7 +2449,8 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc)
|
||||||
|
|
||||||
n = strlen(ptr) + 1;
|
n = strlen(ptr) + 1;
|
||||||
length = __GLX_PAD(n) >> 2;
|
length = __GLX_PAD(n) >> 2;
|
||||||
reply = (xGLXQueryServerStringReply) {
|
|
||||||
|
xGLXQueryServerStringReply reply = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = length,
|
.length = length,
|
||||||
|
|
|
@ -112,7 +112,6 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements,
|
||||||
size_t element_size, GLboolean always_array, CARD32 retval)
|
size_t element_size, GLboolean always_array, CARD32 retval)
|
||||||
{
|
{
|
||||||
size_t reply_ints = 0;
|
size_t reply_ints = 0;
|
||||||
xGLXSingleReply reply = { 0, };
|
|
||||||
|
|
||||||
if (__glXErrorOccured()) {
|
if (__glXErrorOccured()) {
|
||||||
elements = 0;
|
elements = 0;
|
||||||
|
@ -121,11 +120,13 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements,
|
||||||
reply_ints = bytes_to_int32(elements * element_size);
|
reply_ints = bytes_to_int32(elements * element_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.length = reply_ints;
|
xGLXSingleReply reply = {
|
||||||
reply.type = X_Reply;
|
.length = reply_ints,
|
||||||
reply.sequenceNumber = client->sequence;
|
.type = X_Reply,
|
||||||
reply.size = elements;
|
.sequenceNumber = client->sequence,
|
||||||
reply.retval = retval;
|
.size = elements,
|
||||||
|
.retval = retval,
|
||||||
|
};
|
||||||
|
|
||||||
/* It is faster on almost always every architecture to just copy the 8
|
/* 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
|
* bytes, even when not necessary, than check to see of the value of
|
||||||
|
@ -159,7 +160,6 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements,
|
||||||
size_t element_size, GLboolean always_array, CARD32 retval)
|
size_t element_size, GLboolean always_array, CARD32 retval)
|
||||||
{
|
{
|
||||||
size_t reply_ints = 0;
|
size_t reply_ints = 0;
|
||||||
xGLXSingleReply reply = { 0, };
|
|
||||||
|
|
||||||
if (__glXErrorOccured()) {
|
if (__glXErrorOccured()) {
|
||||||
elements = 0;
|
elements = 0;
|
||||||
|
@ -168,11 +168,13 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements,
|
||||||
reply_ints = bytes_to_int32(elements * element_size);
|
reply_ints = bytes_to_int32(elements * element_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.length = bswap_32(reply_ints);
|
xGLXSingleReply reply = {
|
||||||
reply.type = X_Reply;
|
.length = bswap_32(reply_ints),
|
||||||
reply.sequenceNumber = bswap_16(client->sequence);
|
.type = X_Reply,
|
||||||
reply.size = bswap_32(elements);
|
.sequenceNumber = bswap_16(client->sequence),
|
||||||
reply.retval = bswap_32(retval);
|
.size = bswap_32(elements),
|
||||||
|
.retval = bswap_32(retval),
|
||||||
|
};
|
||||||
|
|
||||||
/* It is faster on almost always every architecture to just copy the 8
|
/* 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
|
* bytes, even when not necessary, than check to see of the value of
|
||||||
|
|
|
@ -106,7 +106,6 @@ int
|
||||||
__glXDisp_RenderMode(__GLXclientState * cl, GLbyte * pc)
|
__glXDisp_RenderMode(__GLXclientState * cl, GLbyte * pc)
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
xGLXRenderModeReply reply;
|
|
||||||
__GLXcontext *cx;
|
__GLXcontext *cx;
|
||||||
GLint nitems = 0, retBytes = 0, retval, newModeCheck;
|
GLint nitems = 0, retBytes = 0, retval, newModeCheck;
|
||||||
GLubyte *retBuffer = NULL;
|
GLubyte *retBuffer = NULL;
|
||||||
|
@ -191,7 +190,7 @@ __glXDisp_RenderMode(__GLXclientState * cl, GLbyte * pc)
|
||||||
** selection array, as per the API for glRenderMode itself.
|
** selection array, as per the API for glRenderMode itself.
|
||||||
*/
|
*/
|
||||||
noChangeAllowed:;
|
noChangeAllowed:;
|
||||||
reply = (xGLXRenderModeReply) {
|
xGLXRenderModeReply reply = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = nitems,
|
.length = nitems,
|
||||||
|
@ -230,7 +229,6 @@ __glXDisp_Finish(__GLXclientState * cl, GLbyte * pc)
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
__GLXcontext *cx;
|
__GLXcontext *cx;
|
||||||
int error;
|
int error;
|
||||||
xGLXSingleReply reply = { 0, };
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xGLXSingleReq);
|
REQUEST_SIZE_MATCH(xGLXSingleReq);
|
||||||
|
|
||||||
|
@ -244,6 +242,8 @@ __glXDisp_Finish(__GLXclientState * cl, GLbyte * pc)
|
||||||
|
|
||||||
/* Send empty reply packet to indicate finish is finished */
|
/* Send empty reply packet to indicate finish is finished */
|
||||||
client = cl->client;
|
client = cl->client;
|
||||||
|
|
||||||
|
xGLXSingleReply reply = { 0 };
|
||||||
__GLX_BEGIN_REPLY(0);
|
__GLX_BEGIN_REPLY(0);
|
||||||
__GLX_SEND_HEADER();
|
__GLX_SEND_HEADER();
|
||||||
return Success;
|
return Success;
|
||||||
|
@ -327,7 +327,6 @@ DoGetString(__GLXclientState * cl, GLbyte * pc, GLboolean need_swap)
|
||||||
__GLXcontext *cx;
|
__GLXcontext *cx;
|
||||||
GLenum name;
|
GLenum name;
|
||||||
const char *string;
|
const char *string;
|
||||||
xGLXSingleReply reply = { 0, };
|
|
||||||
|
|
||||||
__GLX_DECLARE_SWAP_VARIABLES;
|
__GLX_DECLARE_SWAP_VARIABLES;
|
||||||
int error;
|
int error;
|
||||||
|
@ -381,6 +380,7 @@ DoGetString(__GLXclientState * cl, GLbyte * pc, GLboolean need_swap)
|
||||||
length = strlen((const char *) string) + 1;
|
length = strlen((const char *) string) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xGLXSingleReply reply = { 0 };
|
||||||
__GLX_BEGIN_REPLY(length);
|
__GLX_BEGIN_REPLY(length);
|
||||||
__GLX_PUT_SIZE(length);
|
__GLX_PUT_SIZE(length);
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,6 @@ __glXDispSwap_RenderMode(__GLXclientState * cl, GLbyte * pc)
|
||||||
{
|
{
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
__GLXcontext *cx;
|
__GLXcontext *cx;
|
||||||
xGLXRenderModeReply reply;
|
|
||||||
GLint nitems = 0, retBytes = 0, retval, newModeCheck;
|
GLint nitems = 0, retBytes = 0, retval, newModeCheck;
|
||||||
GLubyte *retBuffer = NULL;
|
GLubyte *retBuffer = NULL;
|
||||||
GLenum newMode;
|
GLenum newMode;
|
||||||
|
@ -203,7 +202,7 @@ __glXDispSwap_RenderMode(__GLXclientState * cl, GLbyte * pc)
|
||||||
** selection array, as per the API for glRenderMode itself.
|
** selection array, as per the API for glRenderMode itself.
|
||||||
*/
|
*/
|
||||||
noChangeAllowed:;
|
noChangeAllowed:;
|
||||||
reply = (xGLXRenderModeReply) {
|
xGLXRenderModeReply reply = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = nitems,
|
.length = nitems,
|
||||||
|
@ -250,7 +249,6 @@ __glXDispSwap_Finish(__GLXclientState * cl, GLbyte * pc)
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
__GLXcontext *cx;
|
__GLXcontext *cx;
|
||||||
int error;
|
int error;
|
||||||
xGLXSingleReply reply = { 0, };
|
|
||||||
|
|
||||||
__GLX_DECLARE_SWAP_VARIABLES;
|
__GLX_DECLARE_SWAP_VARIABLES;
|
||||||
|
|
||||||
|
@ -266,6 +264,7 @@ __glXDispSwap_Finish(__GLXclientState * cl, GLbyte * pc)
|
||||||
glFinish();
|
glFinish();
|
||||||
|
|
||||||
/* Send empty reply packet to indicate finish is finished */
|
/* Send empty reply packet to indicate finish is finished */
|
||||||
|
xGLXSingleReply reply = { 0 };
|
||||||
__GLX_BEGIN_REPLY(0);
|
__GLX_BEGIN_REPLY(0);
|
||||||
__GLX_PUT_RETVAL(0);
|
__GLX_PUT_RETVAL(0);
|
||||||
__GLX_SWAP_REPLY_HEADER();
|
__GLX_SWAP_REPLY_HEADER();
|
||||||
|
|
Loading…
Reference in New Issue