[PATCH v2 20/29] Use C99 designated initializers in dmx Replies
Alan Coopersmith
alan.coopersmith at oracle.com
Wed Jul 4 15:37:34 PDT 2012
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
hw/dmx/dmx.c | 213 +++++++++++++++++++++++------------------
hw/dmx/glxProxy/glxcmds.c | 110 ++++++++++++---------
hw/dmx/glxProxy/glxcmdsswap.c | 14 +--
hw/dmx/glxProxy/glxsingle.c | 40 ++++----
4 files changed, 216 insertions(+), 161 deletions(-)
diff --git a/hw/dmx/dmx.c b/hw/dmx/dmx.c
index 5ea133e..9df94a4 100644
--- a/hw/dmx/dmx.c
+++ b/hw/dmx/dmx.c
@@ -208,16 +208,17 @@ dmxFetchInputAttributes(unsigned int mask,
static int
ProcDMXQueryVersion(ClientPtr client)
{
- xDMXQueryVersionReply rep;
+ xDMXQueryVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = SERVER_DMX_MAJOR_VERSION,
+ .minorVersion = SERVER_DMX_MINOR_VERSION,
+ .patchVersion = SERVER_DMX_PATCH_VERSION
+ };
REQUEST_SIZE_MATCH(xDMXQueryVersionReq);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.majorVersion = SERVER_DMX_MAJOR_VERSION;
- rep.minorVersion = SERVER_DMX_MINOR_VERSION;
- rep.patchVersion = SERVER_DMX_PATCH_VERSION;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -238,10 +239,12 @@ ProcDMXSync(ClientPtr client)
dmxFlushPendingSyncs();
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.status = 0;
+ rep = (xDMXSyncReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = 0
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -288,10 +291,12 @@ ProcDMXForceWindowCreation(ClientPtr client)
dmxForceWindowCreation(pWin);
doreply:
dmxFlushPendingSyncs();
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.status = 0;
+ rep = (xDMXForceWindowCreationReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = 0
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -308,10 +313,12 @@ ProcDMXGetScreenCount(ClientPtr client)
REQUEST_SIZE_MATCH(xDMXGetScreenCountReq);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.screenCount = dmxGetNumScreens();
+ rep = (xDMXGetScreenCountReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .screenCount = dmxGetNumScreens()
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -339,27 +346,29 @@ ProcDMXGetScreenAttributes(ClientPtr client)
if (!dmxGetScreenAttributes(stuff->physicalScreen, &attr))
return BadValue;
- rep.logicalScreen = attr.logicalScreen;
- rep.screenWindowWidth = attr.screenWindowWidth;
- rep.screenWindowHeight = attr.screenWindowHeight;
- rep.screenWindowXoffset = attr.screenWindowXoffset;
- rep.screenWindowYoffset = attr.screenWindowYoffset;
- rep.rootWindowWidth = attr.rootWindowWidth;
- rep.rootWindowHeight = attr.rootWindowHeight;
- rep.rootWindowXoffset = attr.rootWindowXoffset;
- rep.rootWindowYoffset = attr.rootWindowYoffset;
- rep.rootWindowXorigin = attr.rootWindowXorigin;
- rep.rootWindowYorigin = attr.rootWindowYorigin;
-
length = attr.displayName ? strlen(attr.displayName) : 0;
paddedLength = pad_to_int32(length);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length =
- bytes_to_int32((sizeof(xDMXGetScreenAttributesReply) -
- sizeof(xGenericReply))
- + paddedLength);
- rep.displayNameLength = length;
+
+ rep = (xDMXGetScreenAttributesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length =
+ bytes_to_int32((sizeof(xDMXGetScreenAttributesReply) -
+ sizeof(xGenericReply))
+ + paddedLength),
+ .displayNameLength = length,
+ .logicalScreen = attr.logicalScreen,
+ .screenWindowWidth = attr.screenWindowWidth,
+ .screenWindowHeight = attr.screenWindowHeight,
+ .screenWindowXoffset = attr.screenWindowXoffset,
+ .screenWindowYoffset = attr.screenWindowYoffset,
+ .rootWindowWidth = attr.rootWindowWidth,
+ .rootWindowHeight = attr.rootWindowHeight,
+ .rootWindowXoffset = attr.rootWindowXoffset,
+ .rootWindowYoffset = attr.rootWindowYoffset,
+ .rootWindowXorigin = attr.rootWindowXorigin,
+ .rootWindowYorigin = attr.rootWindowYorigin
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
@@ -442,11 +451,13 @@ ProcDMXChangeScreensAttributes(ClientPtr client)
return status;
noxinerama:
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.status = status;
- rep.errorScreen = errorScreen;
+ rep = (xDMXChangeScreensAttributesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = status,
+ .errorScreen = errorScreen
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -491,11 +502,13 @@ ProcDMXAddScreen(ClientPtr client)
free(name);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.status = status;
- rep.physicalScreen = stuff->physicalScreen;
+ rep = (xDMXAddScreenReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = status,
+ .physicalScreen = stuff->physicalScreen
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -517,10 +530,12 @@ ProcDMXRemoveScreen(ClientPtr client)
status = dmxDetachScreen(stuff->physicalScreen);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.status = status;
+ rep = (xDMXRemoveScreenReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = status
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -636,10 +651,12 @@ ProcDMXGetWindowAttributes(ClientPtr client)
return BadWindow;
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = count * 6;
- rep.screenCount = count;
+ rep = (xDMXGetWindowAttributesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = count * 6,
+ .screenCount = count
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -688,14 +705,15 @@ ProcDMXGetDesktopAttributes(ClientPtr client)
dmxGetDesktopAttributes(&attr);
- rep.width = attr.width;
- rep.height = attr.height;
- rep.shiftX = attr.shiftX;
- rep.shiftY = attr.shiftY;
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
+ rep = (xDMXGetDesktopAttributesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .width = attr.width,
+ .height = attr.height,
+ .shiftX = attr.shiftX,
+ .shiftY = attr.shiftY
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
@@ -739,10 +757,12 @@ ProcDMXChangeDesktopAttributes(ClientPtr client)
return status;
noxinerama:
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.status = status;
+ rep = (xDMXChangeDesktopAttributesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = status
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -759,10 +779,12 @@ ProcDMXGetInputCount(ClientPtr client)
REQUEST_SIZE_MATCH(xDMXGetInputCountReq);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.inputCount = dmxGetInputCount();
+ rep = (xDMXGetInputCountReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .inputCount = dmxGetInputCount()
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -785,19 +807,24 @@ ProcDMXGetInputAttributes(ClientPtr client)
if (dmxGetInputAttributes(stuff->deviceId, &attr))
return BadValue;
- rep.inputType = attr.inputType;
- rep.physicalScreen = attr.physicalScreen;
- rep.physicalId = attr.physicalId;
- rep.isCore = attr.isCore;
- rep.sendsCore = attr.sendsCore;
- rep.detached = attr.detached;
length = attr.name ? strlen(attr.name) : 0;
paddedLength = pad_to_int32(length);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = bytes_to_int32(paddedLength);
- rep.nameLength = length;
+
+ rep = (xDMXGetInputAttributesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(paddedLength),
+
+ .inputType = attr.inputType,
+ .physicalScreen = attr.physicalScreen,
+ .physicalId = attr.physicalId,
+ .nameLength = length,
+ .isCore = attr.isCore,
+ .sendsCore = attr.sendsCore,
+ .detached = attr.detached
+ };
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -849,11 +876,13 @@ ProcDMXAddInput(ClientPtr client)
if (status)
return status;
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.status = status;
- rep.physicalId = id;
+ rep = (xDMXAddInputReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = status,
+ .physicalId = id
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -878,10 +907,12 @@ ProcDMXRemoveInput(ClientPtr client)
if (status)
return status;
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.status = status;
+ rep = (xDMXRemoveInputReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .status = status
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index 32684fa..3410482 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -454,12 +454,12 @@ __glXQueryMaxSwapBarriersSGIX(__GLXclientState * cl, GLbyte * pc)
ClientPtr client = cl->client;
xGLXQueryMaxSwapBarriersSGIXReq *req =
(xGLXQueryMaxSwapBarriersSGIXReq *) pc;
- xGLXQueryMaxSwapBarriersSGIXReply reply;
-
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = 0;
- reply.max = QueryMaxSwapBarriersSGIX(req->screen);
+ xGLXQueryMaxSwapBarriersSGIXReply reply = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .max = QueryMaxSwapBarriersSGIX(req->screen)
+ };
if (client->swapped) {
__glXSwapQueryMaxSwapBarriersSGIXReply(client, &reply);
@@ -793,7 +793,11 @@ MakeCurrent(__GLXclientState * cl,
ClientPtr client = cl->client;
DrawablePtr pDraw = NULL;
DrawablePtr pReadDraw = NULL;
- xGLXMakeCurrentReadSGIReply new_reply;
+ xGLXMakeCurrentReadSGIReply new_reply = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0
+ };
xGLXMakeCurrentReq *be_req;
xGLXMakeCurrentReply be_reply;
xGLXMakeContextCurrentReq *be_new_req;
@@ -1197,9 +1201,6 @@ MakeCurrent(__GLXclientState * cl,
else {
new_reply.contextTag = 0;
}
- new_reply.length = 0;
- new_reply.type = X_Reply;
- new_reply.sequenceNumber = client->sequence;
#ifdef PANORAMIX
if (!noPanoramiXExtension) {
@@ -1438,10 +1439,12 @@ __glXIsDirect(__GLXclientState * cl, GLbyte * pc)
return __glXBadContext;
}
- reply.isDirect = 0;
- reply.length = 0;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
+ reply = (xGLXIsDirectReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .isDirect = 0
+ };
if (client->swapped) {
__glXSwapIsDirectReply(client, &reply);
@@ -1459,18 +1462,19 @@ __glXQueryVersion(__GLXclientState * cl, GLbyte * pc)
ClientPtr client = cl->client;
/* xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc; */
- xGLXQueryVersionReply reply;
+ xGLXQueryVersionReply reply = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
/*
** Server should take into consideration the version numbers sent by the
** client if it wants to work with older clients; however, in this
** implementation the server just returns its version number.
*/
- reply.majorVersion = __glXVersionMajor;
- reply.minorVersion = __glXVersionMinor;
- reply.length = 0;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
+ .majorVersion = __glXVersionMajor,
+ .minorVersion = __glXVersionMinor
+ };
if (client->swapped) {
__glXSwapQueryVersionReply(client, &reply);
@@ -1680,12 +1684,14 @@ __glXGetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
}
pGlxScreen = &__glXActiveScreens[screen];
- reply.numVisuals = pGlxScreen->numGLXVisuals;
- reply.numProps = __GLX_TOTAL_CONFIG;
- reply.length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 *
- __GLX_TOTAL_CONFIG) >> 2;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
+ xGLXGetVisualConfigsReply reply = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .numVisuals = pGlxScreen->numGLXVisuals,
+ .numProps = __GLX_TOTAL_CONFIG,
+ .length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 *
+ __GLX_TOTAL_CONFIG) >> 2
+ };
WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
@@ -2625,10 +2631,12 @@ __glXQueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
#endif
length = len;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = len;
- reply.n = numbytes;
+ reply = (xGLXQueryExtensionsStringReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = len,
+ .n = numbytes
+ };
if (client->swapped) {
glxSwapQueryExtensionsStringReply(client, &reply, be_buf);
@@ -2706,10 +2714,12 @@ __glXQueryServerString(__GLXclientState * cl, GLbyte * pc)
#endif
length = len;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = length;
- reply.n = numbytes;
+ reply = (xGLXQueryServerStringReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = length,
+ .n = numbytes
+ };
if (client->swapped) {
glxSwapQueryServerStringReply(client, &reply, be_buf);
@@ -2863,11 +2873,13 @@ __glXGetFBConfigs(__GLXclientState * cl, GLbyte * pc)
pGlxScreen = &__glXActiveScreens[screen];
numFBConfigs = __glXNumFBConfigs;
- reply.numFBConfigs = numFBConfigs;
- reply.numAttribs = numAttribs;
- reply.length = (numFBConfigs * 2 * numAttribs * __GLX_SIZE_CARD32) >> 2;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
+ reply = (xGLXGetFBConfigsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = (numFBConfigs * 2 * numAttribs * __GLX_SIZE_CARD32) >> 2,
+ .numFBConfigs = numFBConfigs,
+ .numAttribs = numAttribs
+ };
if (client->swapped) {
__GLX_DECLARE_SWAP_VARIABLES;
@@ -3195,10 +3207,12 @@ __glXQueryContext(__GLXclientState * cl, GLbyte * pc)
nProps = 3;
- reply.length = nProps << 1;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.n = nProps;
+ reply = (xGLXQueryContextReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = nProps << 1,
+ .n = nProps
+ };
nReplyBytes = reply.length << 2;
sendBuf = (int *) malloc(nReplyBytes);
@@ -3245,10 +3259,12 @@ __glXQueryContextInfoEXT(__GLXclientState * cl, GLbyte * pc)
nProps = 4;
- reply.length = nProps << 1;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.n = nProps;
+ reply = (xGLXQueryContextInfoEXTReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = nProps << 1,
+ .n = nProps
+ };
nReplyBytes = reply.length << 2;
sendBuf = (int *) malloc(nReplyBytes);
diff --git a/hw/dmx/glxProxy/glxcmdsswap.c b/hw/dmx/glxProxy/glxcmdsswap.c
index a11c919..ac79cda 100644
--- a/hw/dmx/glxProxy/glxcmdsswap.c
+++ b/hw/dmx/glxProxy/glxcmdsswap.c
@@ -293,12 +293,14 @@ __glXSwapGetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
}
pGlxScreen = &__glXActiveScreens[screen];
- reply.numVisuals = pGlxScreen->numGLXVisuals;
- reply.numProps = __GLX_TOTAL_CONFIG;
- reply.length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 *
- __GLX_TOTAL_CONFIG) >> 2;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
+ reply = (xGLXGetVisualConfigsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 *
+ __GLX_TOTAL_CONFIG) >> 2,
+ .numVisuals = pGlxScreen->numGLXVisuals,
+ .numProps = __GLX_TOTAL_CONFIG
+ };
__GLX_SWAP_SHORT(&reply.sequenceNumber);
__GLX_SWAP_INT(&reply.length);
diff --git a/hw/dmx/glxProxy/glxsingle.c b/hw/dmx/glxProxy/glxsingle.c
index 2253060..8784200 100644
--- a/hw/dmx/glxProxy/glxsingle.c
+++ b/hw/dmx/glxProxy/glxsingle.c
@@ -269,13 +269,15 @@ __glXForwardPipe0WithReply(__GLXclientState * cl, GLbyte * pc)
/*
* send the reply to the client
*/
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = be_reply.length;
- reply.retval = be_reply.retval;
- reply.size = be_reply.size;
- reply.pad3 = be_reply.pad3;
- reply.pad4 = be_reply.pad4;
+ reply = (xGLXSingleReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = be_reply.length,
+ .retval = be_reply.retval,
+ .size = be_reply.size,
+ .pad3 = be_reply.pad3,
+ .pad4 = be_reply.pad4
+ };
if (client->swapped) {
SendSwappedReply(client, &reply, be_buf, be_buf_size);
@@ -371,13 +373,15 @@ __glXForwardAllWithReply(__GLXclientState * cl, GLbyte * pc)
/*
* send the reply to the client
*/
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = be_reply.length;
- reply.retval = be_reply.retval;
- reply.size = be_reply.size;
- reply.pad3 = be_reply.pad3;
- reply.pad4 = be_reply.pad4;
+ reply = (xGLXSingleReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = be_reply.length,
+ .retval = be_reply.retval,
+ .size = be_reply.size,
+ .pad3 = be_reply.pad3,
+ .pad4 = be_reply.pad4
+ };
if (client->swapped) {
SendSwappedReply(client, &reply, be_buf, be_buf_size);
@@ -1004,9 +1008,11 @@ __glXDisp_ReadPixels(__GLXclientState * cl, GLbyte * pc)
} /* of if buf_size > 0 */
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = buf_size >> 2;
+ reply = (xGLXReadPixelsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = buf_size >> 2
+ };
if (client->swapped) {
__GLX_SWAP_SHORT(&reply.sequenceNumber);
--
1.7.9.2
More information about the xorg-devel
mailing list