[PATCH v2 16/29] Use C99 designated initializers in various extension Replies

Alan Coopersmith alan.coopersmith at oracle.com
Wed Jul 4 15:37:30 PDT 2012


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 composite/compext.c   |   29 +++++++++++++++++------------
 damageext/damageext.c |   10 ++++++----
 dbe/dbe.c             |   34 ++++++++++++++++++----------------
 record/record.c       |   27 +++++++++++++++------------
 render/render.c       |   10 +++++-----
 xfixes/cursor.c       |   12 +++++++-----
 xfixes/xfixes.c       |   10 +++++-----
 7 files changed, 73 insertions(+), 59 deletions(-)

diff --git a/composite/compext.c b/composite/compext.c
index be25b27..eea1a58 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -107,14 +107,15 @@ static int
 ProcCompositeQueryVersion(ClientPtr client)
 {
     CompositeClientPtr pCompositeClient = GetCompositeClient(client);
-    xCompositeQueryVersionReply rep;
+    xCompositeQueryVersionReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
 
     REQUEST(xCompositeQueryVersionReq);
 
     REQUEST_SIZE_MATCH(xCompositeQueryVersionReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
     if (stuff->majorVersion < SERVER_COMPOSITE_MAJOR_VERSION) {
         rep.majorVersion = stuff->majorVersion;
         rep.minorVersion = stuff->minorVersion;
@@ -311,10 +312,12 @@ ProcCompositeGetOverlayWindow(ClientPtr client)
         return rc;
     }
 
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 0;
-    rep.overlayWin = cs->pOverlayWin->drawable.id;
+    rep = (xCompositeGetOverlayWindowReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .overlayWin = cs->pOverlayWin->drawable.id
+    };
 
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
@@ -842,10 +845,12 @@ PanoramiXCompositeGetOverlayWindow(ClientPtr client)
 
     cs = GetCompScreen(screenInfo.screens[0]);
 
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 0;
-    rep.overlayWin = cs->pOverlayWin->drawable.id;
+    rep = (xCompositeGetOverlayWindowReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .overlayWin = cs->pOverlayWin->drawable.id
+    };
 
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
diff --git a/damageext/damageext.c b/damageext/damageext.c
index 70d2eee..2eddfb3 100644
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -126,14 +126,16 @@ static int
 ProcDamageQueryVersion(ClientPtr client)
 {
     DamageClientPtr pDamageClient = GetDamageClient(client);
-    xDamageQueryVersionReply rep;
+    xDamageQueryVersionReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
 
     REQUEST(xDamageQueryVersionReq);
 
     REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
+
     if (stuff->majorVersion < SERVER_DAMAGE_MAJOR_VERSION) {
         rep.majorVersion = stuff->majorVersion;
         rep.minorVersion = stuff->minorVersion;
diff --git a/dbe/dbe.c b/dbe/dbe.c
index d8010ff..8f3d1b0 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -118,16 +118,16 @@ static int
 ProcDbeGetVersion(ClientPtr client)
 {
     /* REQUEST(xDbeGetVersionReq); */
-    xDbeGetVersionReply rep;
+    xDbeGetVersionReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .majorVersion = DBE_MAJOR_VERSION,
+        .minorVersion = DBE_MINOR_VERSION
+    };
 
     REQUEST_SIZE_MATCH(xDbeGetVersionReq);
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.majorVersion = DBE_MAJOR_VERSION;
-    rep.minorVersion = DBE_MINOR_VERSION;
-
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
     }
@@ -667,10 +667,12 @@ ProcDbeGetVisualInfo(ClientPtr client)
         length += pScrVisInfo[i].count * sizeof(xDbeVisInfo);
     }
 
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = bytes_to_int32(length);
-    rep.m = count;
+    rep = (xDbeGetVisualInfoReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = bytes_to_int32(length),
+        .m = count
+    };
 
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
@@ -755,7 +757,11 @@ static int
 ProcDbeGetBackBufferAttributes(ClientPtr client)
 {
     REQUEST(xDbeGetBackBufferAttributesReq);
-    xDbeGetBackBufferAttributesReply rep;
+    xDbeGetBackBufferAttributesReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
     DbeWindowPrivPtr pDbeWindowPriv;
     int rc;
 
@@ -771,10 +777,6 @@ ProcDbeGetBackBufferAttributes(ClientPtr client)
         rep.attributes = None;
     }
 
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 0;
-
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swapl(&rep.length);
diff --git a/record/record.c b/record/record.c
index 54a0e68..67569d9 100644
--- a/record/record.c
+++ b/record/record.c
@@ -1816,14 +1816,15 @@ static int
 ProcRecordQueryVersion(ClientPtr client)
 {
     /* REQUEST(xRecordQueryVersionReq); */
-    xRecordQueryVersionReply rep;
+    xRecordQueryVersionReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .majorVersion = SERVER_RECORD_MAJOR_VERSION,
+        .minorVersion = SERVER_RECORD_MINOR_VERSION
+    };
 
     REQUEST_SIZE_MATCH(xRecordQueryVersionReq);
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 0;
-    rep.majorVersion = SERVER_RECORD_MAJOR_VERSION;
-    rep.minorVersion = SERVER_RECORD_MINOR_VERSION;
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swaps(&rep.majorVersion);
@@ -2231,12 +2232,14 @@ ProcRecordGetContext(ClientPtr client)
 
     /* write the reply header */
 
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = length;
-    rep.enabled = pContext->pRecordingClient != NULL;
-    rep.elementHeader = pContext->elemHeaders;
-    rep.nClients = nClients;
+    rep = (xRecordGetContextReply) {
+        .type = X_Reply,
+        .enabled = pContext->pRecordingClient != NULL,
+        .sequenceNumber = client->sequence,
+        .length = length,
+        .elementHeader = pContext->elemHeaders,
+        .nClients = nClients
+    };
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swapl(&rep.length);
diff --git a/render/render.c b/render/render.c
index 3bf0702..5301811 100644
--- a/render/render.c
+++ b/render/render.c
@@ -267,7 +267,11 @@ static int
 ProcRenderQueryVersion(ClientPtr client)
 {
     RenderClientPtr pRenderClient = GetRenderClient(client);
-    xRenderQueryVersionReply rep;
+    xRenderQueryVersionReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
 
     REQUEST(xRenderQueryVersionReq);
 
@@ -275,10 +279,6 @@ ProcRenderQueryVersion(ClientPtr client)
     pRenderClient->minor_version = stuff->minorVersion;
 
     REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
-    memset(&rep, 0, sizeof(xRenderQueryVersionReply));
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
 
     if ((stuff->majorVersion * 1000 + stuff->minorVersion) <
         (SERVER_RENDER_MAJOR_VERSION * 1000 + SERVER_RENDER_MINOR_VERSION)) {
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 402456d..68f7b74 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -474,11 +474,13 @@ ProcXFixesGetCursorName(ClientPtr client)
         str = "";
     len = strlen(str);
 
-    reply.type = X_Reply;
-    reply.length = bytes_to_int32(len);
-    reply.sequenceNumber = client->sequence;
-    reply.atom = pCursor->name;
-    reply.nbytes = len;
+    reply = (xXFixesGetCursorNameReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = bytes_to_int32(len),
+        .atom = pCursor->name,
+        .nbytes = len
+    };
     if (client->swapped) {
         swaps(&reply.sequenceNumber);
         swapl(&reply.length);
diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index 54f84f4..c6dd19e 100644
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -61,15 +61,15 @@ static int
 ProcXFixesQueryVersion(ClientPtr client)
 {
     XFixesClientPtr pXFixesClient = GetXFixesClient(client);
-    xXFixesQueryVersionReply rep;
+    xXFixesQueryVersionReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
 
     REQUEST(xXFixesQueryVersionReq);
 
     REQUEST_SIZE_MATCH(xXFixesQueryVersionReq);
-    memset(&rep, 0, sizeof(xXFixesQueryVersionReply));
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
 
     if (version_compare(stuff->majorVersion, stuff->minorVersion,
                         SERVER_XFIXES_MAJOR_VERSION,
-- 
1.7.9.2



More information about the xorg-devel mailing list