[PATCH 13/19] Use C99 designated initializers in xf86 extension Replies

Alan Coopersmith alan.coopersmith at oracle.com
Sun Jun 24 10:25:20 PDT 2012


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 hw/xfree86/dixmods/extmod/xf86dga2.c  |  176 ++++++++++--------
 hw/xfree86/dixmods/extmod/xf86vmode.c |  318 ++++++++++++++++++---------------
 hw/xfree86/dri/xf86dri.c              |  202 +++++++++++----------
 hw/xfree86/dri2/dri2ext.c             |  149 ++++++++-------
 4 files changed, 456 insertions(+), 389 deletions(-)

diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c
index 1ed6a50..a9353a6 100644
--- a/hw/xfree86/dixmods/extmod/xf86dga2.c
+++ b/hw/xfree86/dixmods/extmod/xf86dga2.c
@@ -75,14 +75,15 @@ XDGAResetProc(ExtensionEntry * extEntry)
 static int
 ProcXDGAQueryVersion(ClientPtr client)
 {
-    xXDGAQueryVersionReply rep;
+    xXDGAQueryVersionReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .majorVersion = SERVER_XDGA_MAJOR_VERSION,
+        .minorVersion = SERVER_XDGA_MINOR_VERSION
+    };
 
     REQUEST_SIZE_MATCH(xXDGAQueryVersionReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.majorVersion = SERVER_XDGA_MAJOR_VERSION;
-    rep.minorVersion = SERVER_XDGA_MINOR_VERSION;
 
     WriteToClient(client, sizeof(xXDGAQueryVersionReply), &rep);
     return Success;
@@ -92,7 +93,11 @@ static int
 ProcXDGAOpenFramebuffer(ClientPtr client)
 {
     REQUEST(xXDGAOpenFramebufferReq);
-    xXDGAOpenFramebufferReply rep;
+    xXDGAOpenFramebufferReply rep = {
+        .type = X_Reply,
+        .length = 0,
+        .sequenceNumber = client->sequence
+    };
     char *deviceName;
     int nameSize;
 
@@ -103,9 +108,6 @@ ProcXDGAOpenFramebuffer(ClientPtr client)
         return DGAErrorBase + XF86DGANoDirectVideoMode;
 
     REQUEST_SIZE_MATCH(xXDGAOpenFramebufferReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
 
     if (!DGAOpenFramebuffer(stuff->screen, &deviceName,
                             (unsigned char **) (&rep.mem1),
@@ -148,7 +150,12 @@ ProcXDGAQueryModes(ClientPtr client)
     int i, num, size;
 
     REQUEST(xXDGAQueryModesReq);
-    xXDGAQueryModesReply rep;
+    xXDGAQueryModesReply rep = {
+        .type = X_Reply,
+        .length = 0,
+        .number = 0,
+        .sequenceNumber = client->sequence
+    };
     xXDGAModeInfo info;
     XDGAModePtr mode;
 
@@ -156,10 +163,6 @@ ProcXDGAQueryModes(ClientPtr client)
         return BadValue;
 
     REQUEST_SIZE_MATCH(xXDGAQueryModesReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.number = 0;
-    rep.sequenceNumber = client->sequence;
 
     if (!DGAAvailable(stuff->screen)) {
         rep.number = 0;
@@ -260,7 +263,13 @@ static int
 ProcXDGASetMode(ClientPtr client)
 {
     REQUEST(xXDGASetModeReq);
-    xXDGASetModeReply rep;
+    xXDGASetModeReply rep = {
+        .type = X_Reply,
+        .length = 0,
+        .offset = 0,
+        .flags = 0,
+        .sequenceNumber = client->sequence
+    };
     XDGAModeRec mode;
     xXDGAModeInfo info;
     PixmapPtr pPix;
@@ -272,11 +281,6 @@ ProcXDGASetMode(ClientPtr client)
     owner = DGA_GETCLIENT(stuff->screen);
 
     REQUEST_SIZE_MATCH(xXDGASetModeReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.offset = 0;
-    rep.flags = 0;
-    rep.sequenceNumber = client->sequence;
 
     if (!DGAAvailable(stuff->screen))
         return DGAErrorBase + XF86DGANoDirectVideoMode;
@@ -479,46 +483,52 @@ static int
 ProcXDGAGetViewportStatus(ClientPtr client)
 {
     REQUEST(xXDGAGetViewportStatusReq);
-    xXDGAGetViewportStatusReply rep;
+
+    REQUEST_SIZE_MATCH(xXDGAGetViewportStatusReq);
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
 
     if (DGA_GETCLIENT(stuff->screen) != client)
         return DGAErrorBase + XF86DGADirectNotActivated;
+    else {
+        xXDGAGetViewportStatusReply rep = {
+            .type = X_Reply,
+            .length = 0,
+            .sequenceNumber = client->sequence,
 
-    REQUEST_SIZE_MATCH(xXDGAGetViewportStatusReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    rep.status = DGAGetViewportStatus(stuff->screen);
+            .status = DGAGetViewportStatus(stuff->screen)
+        };
 
-    WriteToClient(client, sizeof(xXDGAGetViewportStatusReply), &rep);
-    return Success;
+        WriteToClient(client, sizeof(xXDGAGetViewportStatusReply), &rep);
+        return Success;
+    }
 }
 
 static int
 ProcXDGASync(ClientPtr client)
 {
     REQUEST(xXDGASyncReq);
-    xXDGASyncReply rep;
+
+    REQUEST_SIZE_MATCH(xXDGASyncReq);
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
 
     if (DGA_GETCLIENT(stuff->screen) != client)
         return DGAErrorBase + XF86DGADirectNotActivated;
+    else {
+        xXDGASyncReply rep = {
+            .type = X_Reply,
+            .length = 0,
+            .sequenceNumber = client->sequence
+        };
 
-    REQUEST_SIZE_MATCH(xXDGASyncReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    DGASync(stuff->screen);
+        DGASync(stuff->screen);
 
-    WriteToClient(client, sizeof(xXDGASyncReply), &rep);
-    return Success;
+        WriteToClient(client, sizeof(xXDGASyncReply), &rep);
+        return Success;
+    }
 }
 
 static int
@@ -546,7 +556,6 @@ static int
 ProcXDGAChangePixmapMode(ClientPtr client)
 {
     REQUEST(xXDGAChangePixmapModeReq);
-    xXDGAChangePixmapModeReply rep;
     int x, y;
 
     if (stuff->screen >= screenInfo.numScreens)
@@ -556,21 +565,25 @@ ProcXDGAChangePixmapMode(ClientPtr client)
         return DGAErrorBase + XF86DGADirectNotActivated;
 
     REQUEST_SIZE_MATCH(xXDGAChangePixmapModeReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
 
     x = stuff->x;
     y = stuff->y;
 
     if (!DGAChangePixmapMode(stuff->screen, &x, &y, stuff->flags))
         return BadMatch;
+    else {
+        xXDGAChangePixmapModeReply rep = {
+            .type = X_Reply,
+            .length = 0,
+            .sequenceNumber = client->sequence,
 
-    rep.x = x;
-    rep.y = y;
-    WriteToClient(client, sizeof(xXDGAChangePixmapModeReply), &rep);
+            .x = x,
+            .y = y
+        };
+        WriteToClient(client, sizeof(xXDGAChangePixmapModeReply), &rep);
 
-    return Success;
+        return Success;
+    }
 }
 
 static int
@@ -610,7 +623,11 @@ static int
 ProcXF86DGAGetVideoLL(ClientPtr client)
 {
     REQUEST(xXF86DGAGetVideoLLReq);
-    xXF86DGAGetVideoLLReply rep;
+    xXF86DGAGetVideoLLReply rep = {
+        .type = X_Reply,
+        .length = 0,
+        .sequenceNumber = client->sequence
+    };
     XDGAModeRec mode;
     int num, offset, flags;
     char *name;
@@ -619,9 +636,6 @@ ProcXF86DGAGetVideoLL(ClientPtr client)
         return BadValue;
 
     REQUEST_SIZE_MATCH(xXF86DGAGetVideoLLReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
 
     if (!DGAAvailable(stuff->screen))
         return DGAErrorBase + XF86DGANoDirectVideoMode;
@@ -711,15 +725,11 @@ ProcXF86DGAGetViewPortSize(ClientPtr client)
     XDGAModeRec mode;
 
     REQUEST(xXF86DGAGetViewPortSizeReq);
-    xXF86DGAGetViewPortSizeReply rep;
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
 
     REQUEST_SIZE_MATCH(xXF86DGAGetViewPortSizeReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
 
     if (!DGAAvailable(stuff->screen))
         return DGAErrorBase + XF86DGANoDirectVideoMode;
@@ -729,10 +739,18 @@ ProcXF86DGAGetViewPortSize(ClientPtr client)
 
     DGAGetModeInfo(stuff->screen, &mode, num);
 
-    rep.width = mode.viewportWidth;
-    rep.height = mode.viewportHeight;
+    {
+        xXF86DGAGetViewPortSizeReply rep = {
+            .type = X_Reply,
+            .length = 0,
+            .sequenceNumber = client->sequence,
+
+            .width = mode.viewportWidth,
+            .height = mode.viewportHeight
+        };
 
-    WriteToClient(client, SIZEOF(xXF86DGAGetViewPortSizeReply), &rep);
+        WriteToClient(client, SIZEOF(xXF86DGAGetViewPortSizeReply), &rep);
+    }
     return Success;
 }
 
@@ -766,16 +784,17 @@ static int
 ProcXF86DGAGetVidPage(ClientPtr client)
 {
     REQUEST(xXF86DGAGetVidPageReq);
-    xXF86DGAGetVidPageReply rep;
+    xXF86DGAGetVidPageReply rep = {
+        .type = X_Reply,
+        .length = 0,
+        .sequenceNumber = client->sequence,
+        .vpage = 0               /* silently fail */
+    };
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
 
     REQUEST_SIZE_MATCH(xXF86DGAGetVidPageReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.vpage = 0;              /* silently fail */
 
     WriteToClient(client, SIZEOF(xXF86DGAGetVidPageReply), &rep);
     return Success;
@@ -830,16 +849,17 @@ static int
 ProcXF86DGAQueryDirectVideo(ClientPtr client)
 {
     REQUEST(xXF86DGAQueryDirectVideoReq);
-    xXF86DGAQueryDirectVideoReply rep;
+    xXF86DGAQueryDirectVideoReply rep = {
+        .type = X_Reply,
+        .length = 0,
+        .sequenceNumber = client->sequence,
+        .flags = 0
+    };
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
 
     REQUEST_SIZE_MATCH(xXF86DGAQueryDirectVideoReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.flags = 0;
 
     if (DGAAvailable(stuff->screen))
         rep.flags = XF86DGADirectPresent;
@@ -852,7 +872,6 @@ static int
 ProcXF86DGAViewPortChanged(ClientPtr client)
 {
     REQUEST(xXF86DGAViewPortChangedReq);
-    xXF86DGAViewPortChangedReply rep;
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
@@ -864,14 +883,17 @@ ProcXF86DGAViewPortChanged(ClientPtr client)
 
     if (!DGAActive(stuff->screen))
         return DGAErrorBase + XF86DGADirectNotActivated;
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.result = 1;
-
-    WriteToClient(client, SIZEOF(xXF86DGAViewPortChangedReply), &rep);
-    return Success;
+    else {
+        xXF86DGAViewPortChangedReply rep = {
+            .type = X_Reply,
+            .length = 0,
+            .sequenceNumber = client->sequence,
+            .result = 1
+        };
+
+        WriteToClient(client, SIZEOF(xXF86DGAViewPortChangedReply), &rep);
+        return Success;
+    }
 }
 
 #endif                          /* DGA_PROTOCOL_OLD_SUPPORT */
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index bd23dc2..1fec0f8 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -280,16 +280,18 @@ SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * from,
 static int
 ProcXF86VidModeQueryVersion(ClientPtr client)
 {
-    xXF86VidModeQueryVersionReply rep;
+    xXF86VidModeQueryVersionReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION,
+        .minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION
+    };
 
     DEBUG_P("XF86VidModeQueryVersion");
 
     REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION;
-    rep.minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION;
+
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swapl(&rep.length);
@@ -304,8 +306,10 @@ static int
 ProcXF86VidModeGetModeLine(ClientPtr client)
 {
     REQUEST(xXF86VidModeGetModeLineReq);
-    xXF86VidModeGetModeLineReply rep;
-    xXF86OldVidModeGetModeLineReply oldrep;
+    xXF86VidModeGetModeLineReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence
+    };
     pointer mode;
     int dotClock;
     int ver;
@@ -314,7 +318,7 @@ ProcXF86VidModeGetModeLine(ClientPtr client)
 
     ver = ClientMajorVersion(client);
     REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
-    rep.type = X_Reply;
+
     if (ver < 2) {
         rep.length = bytes_to_int32(SIZEOF(xXF86OldVidModeGetModeLineReply) -
                                     SIZEOF(xGenericReply));
@@ -323,7 +327,6 @@ ProcXF86VidModeGetModeLine(ClientPtr client)
         rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetModeLineReply) -
                                     SIZEOF(xGenericReply));
     }
-    rep.sequenceNumber = client->sequence;
 
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
@@ -377,20 +380,22 @@ ProcXF86VidModeGetModeLine(ClientPtr client)
         swapl(&rep.privsize);
     }
     if (ver < 2) {
-        oldrep.type = rep.type;
-        oldrep.sequenceNumber = rep.sequenceNumber;
-        oldrep.length = rep.length;
-        oldrep.dotclock = rep.dotclock;
-        oldrep.hdisplay = rep.hdisplay;
-        oldrep.hsyncstart = rep.hsyncstart;
-        oldrep.hsyncend = rep.hsyncend;
-        oldrep.htotal = rep.htotal;
-        oldrep.vdisplay = rep.vdisplay;
-        oldrep.vsyncstart = rep.vsyncstart;
-        oldrep.vsyncend = rep.vsyncend;
-        oldrep.vtotal = rep.vtotal;
-        oldrep.flags = rep.flags;
-        oldrep.privsize = rep.privsize;
+        xXF86OldVidModeGetModeLineReply oldrep = {
+            .type = rep.type,
+            .sequenceNumber = rep.sequenceNumber,
+            .length = rep.length,
+            .dotclock = rep.dotclock,
+            .hdisplay = rep.hdisplay,
+            .hsyncstart = rep.hsyncstart,
+            .hsyncend = rep.hsyncend,
+            .htotal = rep.htotal,
+            .vdisplay = rep.vdisplay,
+            .vsyncstart = rep.vsyncstart,
+            .vsyncend = rep.vsyncend,
+            .vtotal = rep.vtotal,
+            .flags = rep.flags,
+            .privsize = rep.privsize
+        };
         WriteToClient(client, sizeof(xXF86OldVidModeGetModeLineReply), &oldrep);
     }
     else {
@@ -403,7 +408,6 @@ static int
 ProcXF86VidModeGetAllModeLines(ClientPtr client)
 {
     REQUEST(xXF86VidModeGetAllModeLinesReq);
-    xXF86VidModeGetAllModeLinesReply rep;
     xXF86VidModeModeInfo mdinf;
     xXF86OldVidModeModeInfo oldmdinf;
     pointer mode;
@@ -425,23 +429,26 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client)
 
     if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
         return BadValue;
-
-    rep.type = X_Reply;
-    rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
-        SIZEOF(xGenericReply);
-    if (ver < 2)
-        rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
-    else
-        rep.length += modecount * sizeof(xXF86VidModeModeInfo);
-    rep.length >>= 2;
-    rep.sequenceNumber = client->sequence;
-    rep.modecount = modecount;
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
-        swapl(&rep.modecount);
+    else {
+        xXF86VidModeGetAllModeLinesReply rep = {
+            .type = X_Reply,
+            .length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
+                      SIZEOF(xGenericReply),
+            .sequenceNumber = client->sequence,
+            .modecount = modecount
+        };
+        if (ver < 2)
+            rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
+        else
+            rep.length += modecount * sizeof(xXF86VidModeModeInfo);
+        rep.length >>= 2;
+        if (client->swapped) {
+            swaps(&rep.sequenceNumber);
+            swapl(&rep.length);
+            swapl(&rep.modecount);
+        }
+        WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), &rep);
     }
-    WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), &rep);
 
     do {
         mdinf.dotclock = dotClock;
@@ -928,7 +935,6 @@ ProcXF86VidModeValidateModeLine(ClientPtr client)
     xXF86OldVidModeValidateModeLineReq *oldstuff =
         (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
     xXF86VidModeValidateModeLineReq newstuff;
-    xXF86VidModeValidateModeLineReply rep;
     pointer mode, modetmp = NULL;
     int len, status, dotClock;
     int ver;
@@ -1025,17 +1031,21 @@ ProcXF86VidModeValidateModeLine(ClientPtr client)
  status_reply:
     free(modetmp);
 
-    rep.type = X_Reply;
-    rep.length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply)
-                                - SIZEOF(xGenericReply));
-    rep.sequenceNumber = client->sequence;
-    rep.status = status;
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
-        swapl(&rep.status);
+    {
+        xXF86VidModeValidateModeLineReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply)
+                                     - SIZEOF(xGenericReply)),
+            .status = status
+        };
+        if (client->swapped) {
+            swaps(&rep.sequenceNumber);
+            swapl(&rep.length);
+            swapl(&rep.status);
+        }
+        WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), &rep);
     }
-    WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), &rep);
     if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
         ErrorF("ValidateModeLine - Succeeded (status = %d)\n", status);
     return Success;
@@ -1184,7 +1194,10 @@ static int
 ProcXF86VidModeGetMonitor(ClientPtr client)
 {
     REQUEST(xXF86VidModeGetMonitorReq);
-    xXF86VidModeGetMonitorReply rep;
+    xXF86VidModeGetMonitorReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence
+    };
     CARD32 *hsyncdata, *vsyncdata;
     int i, nHsync, nVrefresh;
     pointer monitor;
@@ -1202,7 +1215,6 @@ ProcXF86VidModeGetMonitor(ClientPtr client)
     nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
     nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i;
 
-    rep.type = X_Reply;
     if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr)
         rep.vendorLength = strlen((char *) (VidModeGetMonitorValue(monitor,
                                                                    VIDMODE_MON_VENDOR,
@@ -1221,7 +1233,7 @@ ProcXF86VidModeGetMonitor(ClientPtr client)
                                                 nVrefresh) * sizeof(CARD32) +
                        pad_to_int32(rep.vendorLength) +
                        pad_to_int32(rep.modelLength));
-    rep.sequenceNumber = client->sequence;
+
     rep.nhsync = nHsync;
     rep.nvsync = nVrefresh;
     hsyncdata = malloc(nHsync * sizeof(CARD32));
@@ -1277,7 +1289,6 @@ static int
 ProcXF86VidModeGetViewPort(ClientPtr client)
 {
     REQUEST(xXF86VidModeGetViewPortReq);
-    xXF86VidModeGetViewPortReply rep;
     int x, y;
 
     DEBUG_P("XF86VidModeGetViewPort");
@@ -1287,21 +1298,25 @@ ProcXF86VidModeGetViewPort(ClientPtr client)
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
     VidModeGetViewPort(stuff->screen, &x, &y);
-    rep.x = x;
-    rep.y = y;
 
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
-        swapl(&rep.x);
-        swapl(&rep.y);
+    {
+        xXF86VidModeGetViewPortReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .x = x,
+            .y = y
+        };
+
+        if (client->swapped) {
+            swaps(&rep.sequenceNumber);
+            swapl(&rep.length);
+            swapl(&rep.x);
+            swapl(&rep.y);
+        }
+        WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply), &rep);
     }
-    WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply), &rep);
     return Success;
 }
 
@@ -1327,7 +1342,6 @@ static int
 ProcXF86VidModeGetDotClocks(ClientPtr client)
 {
     REQUEST(xXF86VidModeGetDotClocksReq);
-    xXF86VidModeGetDotClocksReply rep;
     int n;
     int numClocks;
     CARD32 dotclock;
@@ -1343,13 +1357,6 @@ ProcXF86VidModeGetDotClocks(ClientPtr client)
 
     numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
 
-    rep.type = X_Reply;
-    rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply)
-                                - SIZEOF(xGenericReply) + numClocks);
-    rep.sequenceNumber = client->sequence;
-    rep.clocks = numClocks;
-    rep.maxclocks = MAXCLOCKS;
-    rep.flags = 0;
 
     if (!ClockProg) {
         Clocks = malloc(numClocks * sizeof(int));
@@ -1360,17 +1367,25 @@ ProcXF86VidModeGetDotClocks(ClientPtr client)
             return BadValue;
         }
     }
-    if (ClockProg) {
-        rep.flags |= CLKFLAG_PROGRAMABLE;
-    }
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
-        swapl(&rep.clocks);
-        swapl(&rep.maxclocks);
-        swapl(&rep.flags);
+    {
+        xXF86VidModeGetDotClocksReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply)
+                                     - SIZEOF(xGenericReply) + numClocks),
+            .clocks = numClocks,
+            .maxclocks = MAXCLOCKS,
+            .flags = ClockProg ? CLKFLAG_PROGRAMABLE : 0
+        };
+        if (client->swapped) {
+            swaps(&rep.sequenceNumber);
+            swapl(&rep.length);
+            swapl(&rep.clocks);
+            swapl(&rep.maxclocks);
+            swapl(&rep.flags);
+        }
+        WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), &rep);
     }
-    WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), &rep);
     if (!ClockProg) {
         for (n = 0; n < numClocks; n++) {
             dotclock = *Clocks++;
@@ -1411,7 +1426,6 @@ static int
 ProcXF86VidModeGetGamma(ClientPtr client)
 {
     REQUEST(xXF86VidModeGetGammaReq);
-    xXF86VidModeGetGammaReply rep;
     float red, green, blue;
 
     DEBUG_P("XF86VidModeGetGamma");
@@ -1421,24 +1435,28 @@ ProcXF86VidModeGetGamma(ClientPtr client)
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
     if (!VidModeGetGamma(stuff->screen, &red, &green, &blue))
         return BadValue;
-    rep.red = (CARD32) (red * 10000.);
-    rep.green = (CARD32) (green * 10000.);
-    rep.blue = (CARD32) (blue * 10000.);
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
-        swapl(&rep.red);
-        swapl(&rep.green);
-        swapl(&rep.blue);
-    }
-    WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), &rep);
+    else {
+        xXF86VidModeGetGammaReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .red = (CARD32) (red * 10000.),
+            .green = (CARD32) (green * 10000.),
+            .blue = (CARD32) (blue * 10000.)
+        };
+        if (client->swapped) {
+            swaps(&rep.sequenceNumber);
+            swapl(&rep.length);
+            swapl(&rep.red);
+            swapl(&rep.green);
+            swapl(&rep.blue);
+        }
+        WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), &rep);
 
-    return Success;
+        return Success;
+    }
 }
 
 static int
@@ -1475,7 +1493,6 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client)
     CARD16 *ramp = NULL;
     int length;
     size_t ramplen = 0;
-    xXF86VidModeGetGammaRampReply rep;
 
     REQUEST(xXF86VidModeGetGammaRampReq);
 
@@ -1500,17 +1517,22 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client)
             return BadValue;
         }
     }
-    rep.type = X_Reply;
-    rep.length = (length >> 1) * 3;
-    rep.sequenceNumber = client->sequence;
-    rep.size = stuff->size;
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
-        swaps(&rep.size);
-        SwapShorts((short *) ramp, length * 3);
+
+    {
+        xXF86VidModeGetGammaRampReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = (length >> 1) * 3,
+            .size = stuff->size
+        };
+        if (client->swapped) {
+            swaps(&rep.sequenceNumber);
+            swapl(&rep.length);
+            swaps(&rep.size);
+            SwapShorts((short *) ramp, length * 3);
+        }
+        WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), &rep);
     }
-    WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), &rep);
 
     if (stuff->size) {
         WriteToClient(client, ramplen, ramp);
@@ -1523,57 +1545,59 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client)
 static int
 ProcXF86VidModeGetGammaRampSize(ClientPtr client)
 {
-    xXF86VidModeGetGammaRampSizeReply rep;
-
     REQUEST(xXF86VidModeGetGammaRampSizeReq);
 
+    REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
+
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    else {
+        xXF86VidModeGetGammaRampSizeReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .size = VidModeGetGammaRampSize(stuff->screen)
+        };
+        if (client->swapped) {
+            swaps(&rep.sequenceNumber);
+            swapl(&rep.length);
+            swaps(&rep.size);
+        }
+        WriteToClient(client, sizeof(xXF86VidModeGetGammaRampSizeReply), &rep);
 
-    REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.size = VidModeGetGammaRampSize(stuff->screen);
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
-        swaps(&rep.size);
+        return Success;
     }
-    WriteToClient(client, sizeof(xXF86VidModeGetGammaRampSizeReply), &rep);
-
-    return Success;
 }
 
 static int
 ProcXF86VidModeGetPermissions(ClientPtr client)
 {
-    xXF86VidModeGetPermissionsReply rep;
-
     REQUEST(xXF86VidModeGetPermissionsReq);
 
+    REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
+
     if (stuff->screen >= screenInfo.numScreens)
         return BadValue;
+    else {
+        xXF86VidModeGetPermissionsReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .permissions = XF86VM_READ_PERMISSION
+        };
+        if (xf86GetVidModeEnabled() &&
+            (xf86GetVidModeAllowNonLocal() || LocalClient(client))) {
+            rep.permissions |= XF86VM_WRITE_PERMISSION;
+        }
+        if (client->swapped) {
+            swaps(&rep.sequenceNumber);
+            swapl(&rep.length);
+            swapl(&rep.permissions);
+        }
+        WriteToClient(client, sizeof(xXF86VidModeGetPermissionsReply), &rep);
 
-    REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.permissions = XF86VM_READ_PERMISSION;
-    if (xf86GetVidModeEnabled() &&
-        (xf86GetVidModeAllowNonLocal() || LocalClient(client))) {
-        rep.permissions |= XF86VM_WRITE_PERMISSION;
-    }
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
-        swapl(&rep.permissions);
+        return Success;
     }
-    WriteToClient(client, sizeof(xXF86VidModeGetPermissionsReply), &rep);
-
-    return Success;
 }
 
 static int
diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c
index ee7b213..79425c9 100644
--- a/hw/xfree86/dri/xf86dri.c
+++ b/hw/xfree86/dri/xf86dri.c
@@ -78,15 +78,16 @@ XF86DRIResetProc(ExtensionEntry * extEntry)
 static int
 ProcXF86DRIQueryVersion(register ClientPtr client)
 {
-    xXF86DRIQueryVersionReply rep;
+    xXF86DRIQueryVersionReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .majorVersion = SERVER_XF86DRI_MAJOR_VERSION,
+        .minorVersion = SERVER_XF86DRI_MINOR_VERSION,
+        .patchVersion = SERVER_XF86DRI_PATCH_VERSION
+    };
 
     REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.majorVersion = SERVER_XF86DRI_MAJOR_VERSION;
-    rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION;
-    rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION;
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swapl(&rep.length);
@@ -101,7 +102,6 @@ ProcXF86DRIQueryVersion(register ClientPtr client)
 static int
 ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
 {
-    xXF86DRIQueryDirectRenderingCapableReply rep;
     Bool isCapable;
 
     REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
@@ -111,34 +111,36 @@ ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
         return BadValue;
     }
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
     if (!DRIQueryDirectRenderingCapable(screenInfo.screens[stuff->screen],
                                         &isCapable)) {
         return BadValue;
     }
-    rep.isCapable = isCapable;
-
-    if (!LocalClient(client) || client->swapped)
-        rep.isCapable = 0;
+    else {
+        xXF86DRIQueryDirectRenderingCapableReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .isCapable = isCapable
+        };
+
+        if (!LocalClient(client) || client->swapped)
+            rep.isCapable = 0;
+
+        if (client->swapped) {
+            swaps(&rep.sequenceNumber);
+            swapl(&rep.length);
+        }
 
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
+        WriteToClient(client,
+                      sizeof(xXF86DRIQueryDirectRenderingCapableReply),
+                      &rep);
+        return Success;
     }
-
-    WriteToClient(client,
-                  sizeof(xXF86DRIQueryDirectRenderingCapableReply),
-                  &rep);
-    return Success;
 }
 
 static int
 ProcXF86DRIOpenConnection(register ClientPtr client)
 {
-    xXF86DRIOpenConnectionReply rep;
     drm_handle_t hSAREA;
     char *busIdString;
 
@@ -153,53 +155,57 @@ ProcXF86DRIOpenConnection(register ClientPtr client)
                            &hSAREA, &busIdString)) {
         return BadValue;
     }
-
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.busIdStringLength = 0;
-    if (busIdString)
-        rep.busIdStringLength = strlen(busIdString);
-    rep.length =
-        bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) -
-                       SIZEOF(xGenericReply) +
-                       pad_to_int32(rep.busIdStringLength));
-
-    rep.hSAREALow = (CARD32) (hSAREA & 0xffffffff);
+    else {
+        CARD32 busIdStringLength = busIdString ? strlen(busIdString) : 0;
+        xXF86DRIOpenConnectionReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) -
+                                     SIZEOF(xGenericReply) +
+                                     pad_to_int32(busIdStringLength)),
+            .busIdStringLength = busIdStringLength,
+
+            .hSAREALow = (CARD32) (hSAREA & 0xffffffff),
 #if defined(LONG64) && !defined(__linux__)
-    rep.hSAREAHigh = (CARD32) (hSAREA >> 32);
+            .hSAREAHigh = (CARD32) (hSAREA >> 32),
 #else
-    rep.hSAREAHigh = 0;
+            .hSAREAHigh = 0
 #endif
+        };
 
-    WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), &rep);
-    if (rep.busIdStringLength)
-        WriteToClient(client, rep.busIdStringLength, busIdString);
-    return Success;
+        WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), &rep);
+        if (busIdStringLength)
+            WriteToClient(client, busIdStringLength, busIdString);
+        return Success;
+    }
 }
 
 static int
 ProcXF86DRIAuthConnection(register ClientPtr client)
 {
-    xXF86DRIAuthConnectionReply rep;
-
     REQUEST(xXF86DRIAuthConnectionReq);
     REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
     if (stuff->screen >= screenInfo.numScreens) {
         client->errorValue = stuff->screen;
         return BadValue;
     }
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.authenticated = 1;
-
-    if (!DRIAuthConnection(screenInfo.screens[stuff->screen], stuff->magic)) {
-        ErrorF("Failed to authenticate %lu\n", (unsigned long) stuff->magic);
-        rep.authenticated = 0;
+    else {
+        xXF86DRIAuthConnectionReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .authenticated = 1
+        };
+
+        if (!DRIAuthConnection(screenInfo.screens[stuff->screen],
+                               stuff->magic)) {
+            ErrorF("Failed to authenticate %lu\n",
+                   (unsigned long) stuff->magic);
+            rep.authenticated = 0;
+        }
+        WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), &rep);
+        return Success;
     }
-    WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), &rep);
-    return Success;
 }
 
 static int
@@ -220,7 +226,11 @@ ProcXF86DRICloseConnection(register ClientPtr client)
 static int
 ProcXF86DRIGetClientDriverName(register ClientPtr client)
 {
-    xXF86DRIGetClientDriverNameReply rep;
+    xXF86DRIGetClientDriverNameReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .clientDriverNameLength = 0
+    };
     char *clientDriverName;
 
     REQUEST(xXF86DRIGetClientDriverNameReq);
@@ -236,9 +246,6 @@ ProcXF86DRIGetClientDriverName(register ClientPtr client)
                            (int *) &rep.ddxDriverPatchVersion,
                            &clientDriverName);
 
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.clientDriverNameLength = 0;
     if (clientDriverName)
         rep.clientDriverNameLength = strlen(clientDriverName);
     rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) -
@@ -254,30 +261,30 @@ ProcXF86DRIGetClientDriverName(register ClientPtr client)
 static int
 ProcXF86DRICreateContext(register ClientPtr client)
 {
-    xXF86DRICreateContextReply rep;
-    ScreenPtr pScreen;
-
     REQUEST(xXF86DRICreateContextReq);
     REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
     if (stuff->screen >= screenInfo.numScreens) {
         client->errorValue = stuff->screen;
         return BadValue;
     }
+    else {
+        ScreenPtr pScreen = screenInfo.screens[stuff->screen];
+        drm_context_t hHWContext;
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    pScreen = screenInfo.screens[stuff->screen];
-
-    if (!DRICreateContext(pScreen,
-                          NULL,
-                          stuff->context, (drm_context_t *) & rep.hHWContext)) {
-        return BadValue;
+        if (!DRICreateContext(pScreen, NULL, stuff->context, &hHWContext)) {
+            return BadValue;
+        }
+        else {
+            xXF86DRICreateContextReply rep = {
+                .type = X_Reply,
+                .sequenceNumber = client->sequence,
+                .length = 0,
+                .hHWContext = hHWContext
+            };
+            WriteToClient(client, sizeof(xXF86DRICreateContextReply), &rep);
+            return Success;
+        }
     }
-
-    WriteToClient(client, sizeof(xXF86DRICreateContextReply), &rep);
-    return Success;
 }
 
 static int
@@ -300,8 +307,8 @@ ProcXF86DRIDestroyContext(register ClientPtr client)
 static int
 ProcXF86DRICreateDrawable(ClientPtr client)
 {
-    xXF86DRICreateDrawableReply rep;
     DrawablePtr pDrawable;
+    drm_drawable_t hHWDrawable;
     int rc;
 
     REQUEST(xXF86DRICreateDrawableReq);
@@ -311,22 +318,25 @@ ProcXF86DRICreateDrawable(ClientPtr client)
         return BadValue;
     }
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
     rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
                            DixReadAccess);
     if (rc != Success)
         return rc;
 
     if (!DRICreateDrawable(screenInfo.screens[stuff->screen], client,
-                           pDrawable, (drm_drawable_t *) & rep.hHWDrawable)) {
+                           pDrawable, &hHWDrawable)) {
         return BadValue;
     }
-
-    WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), &rep);
-    return Success;
+    else {
+        xXF86DRICreateDrawableReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .hHWDrawable = hHWDrawable
+        };
+        WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), &rep);
+        return Success;
+    }
 }
 
 static int
@@ -359,7 +369,11 @@ ProcXF86DRIDestroyDrawable(register ClientPtr client)
 static int
 ProcXF86DRIGetDrawableInfo(register ClientPtr client)
 {
-    xXF86DRIGetDrawableInfoReply rep;
+    xXF86DRIGetDrawableInfoReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = SIZEOF(xXF86DRIGetDrawableInfoReply) - SIZEOF(xGenericReply)
+    };
     DrawablePtr pDrawable;
     int X, Y, W, H;
     drm_clip_rect_t *pClipRects, *pClippedRects;
@@ -373,10 +387,6 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client)
         return BadValue;
     }
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
     rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
                            DixReadAccess);
     if (rc != Success)
@@ -402,7 +412,6 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client)
     rep.drawableY = Y;
     rep.drawableWidth = W;
     rep.drawableHeight = H;
-    rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - SIZEOF(xGenericReply));
 
     rep.backX = backX;
     rep.backY = backY;
@@ -464,7 +473,11 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client)
 static int
 ProcXF86DRIGetDeviceInfo(register ClientPtr client)
 {
-    xXF86DRIGetDeviceInfoReply rep;
+    xXF86DRIGetDeviceInfoReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
     drm_handle_t hFrameBuffer;
     void *pDevPrivate;
 
@@ -475,10 +488,6 @@ ProcXF86DRIGetDeviceInfo(register ClientPtr client)
         return BadValue;
     }
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
     if (!DRIGetDeviceInfo(screenInfo.screens[stuff->screen],
                           &hFrameBuffer,
                           (int *) &rep.framebufferOrigin,
@@ -495,7 +504,6 @@ ProcXF86DRIGetDeviceInfo(register ClientPtr client)
     rep.hFrameBufferHigh = 0;
 #endif
 
-    rep.length = 0;
     if (rep.devPrivateSize) {
         rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) -
                                     SIZEOF(xGenericReply) +
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index c6f5b4e..ee7f565 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -71,17 +71,18 @@ static int
 ProcDRI2QueryVersion(ClientPtr client)
 {
     REQUEST(xDRI2QueryVersionReq);
-    xDRI2QueryVersionReply rep;
+    xDRI2QueryVersionReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .majorVersion = dri2_major,
+        .minorVersion = dri2_minor
+    };
 
     if (client->swapped)
         swaps(&stuff->length);
 
     REQUEST_SIZE_MATCH(xDRI2QueryVersionReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.majorVersion = dri2_major;
-    rep.minorVersion = dri2_minor;
 
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
@@ -99,7 +100,13 @@ static int
 ProcDRI2Connect(ClientPtr client)
 {
     REQUEST(xDRI2ConnectReq);
-    xDRI2ConnectReply rep;
+    xDRI2ConnectReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .driverNameLength = 0,
+        .deviceNameLength = 0
+    };
     DrawablePtr pDraw;
     int fd, status;
     const char *driverName;
@@ -110,12 +117,6 @@ ProcDRI2Connect(ClientPtr client)
                        &pDraw, &status))
         return status;
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.driverNameLength = 0;
-    rep.deviceNameLength = 0;
-
     if (!DRI2Connect(pDraw->pScreen,
                      stuff->driverType, &fd, &driverName, &deviceName))
         goto fail;
@@ -137,7 +138,6 @@ static int
 ProcDRI2Authenticate(ClientPtr client)
 {
     REQUEST(xDRI2AuthenticateReq);
-    xDRI2AuthenticateReply rep;
     DrawablePtr pDraw;
     int status;
 
@@ -145,14 +145,17 @@ ProcDRI2Authenticate(ClientPtr client)
     if (!validDrawable(client, stuff->window, DixGetAttrAccess,
                        &pDraw, &status))
         return status;
+    else {
+        xDRI2AuthenticateReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .authenticated = DRI2Authenticate(pDraw->pScreen, stuff->magic)
+        };
+        WriteToClient(client, sizeof(xDRI2AuthenticateReply), &rep);
 
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 0;
-    rep.authenticated = DRI2Authenticate(pDraw->pScreen, stuff->magic);
-    WriteToClient(client, sizeof(xDRI2AuthenticateReply), &rep);
-
-    return Success;
+        return Success;
+    }
 }
 
 static void
@@ -207,7 +210,6 @@ static int
 send_buffers_reply(ClientPtr client, DrawablePtr pDrawable,
                    DRI2BufferPtr * buffers, int count, int width, int height)
 {
-    xDRI2GetBuffersReply rep;
     int skip = 0;
     int i;
 
@@ -225,13 +227,17 @@ send_buffers_reply(ClientPtr client, DrawablePtr pDrawable,
         }
     }
 
-    rep.type = X_Reply;
-    rep.length = (count - skip) * sizeof(xDRI2Buffer) / 4;
-    rep.sequenceNumber = client->sequence;
-    rep.width = width;
-    rep.height = height;
-    rep.count = count - skip;
-    WriteToClient(client, sizeof(xDRI2GetBuffersReply), &rep);
+    {
+        xDRI2GetBuffersReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = (count - skip) * sizeof(xDRI2Buffer) / 4,
+            .width = width,
+            .height = height,
+            .count = count - skip
+        };
+        WriteToClient(client, sizeof(xDRI2GetBuffersReply), &rep);
+    }
 
     for (i = 0; i < count; i++) {
         xDRI2Buffer buffer;
@@ -306,7 +312,6 @@ static int
 ProcDRI2CopyRegion(ClientPtr client)
 {
     REQUEST(xDRI2CopyRegionReq);
-    xDRI2CopyRegionReply rep;
     DrawablePtr pDrawable;
     int status;
     RegionPtr pRegion;
@@ -322,21 +327,23 @@ ProcDRI2CopyRegion(ClientPtr client)
     status = DRI2CopyRegion(pDrawable, pRegion, stuff->dest, stuff->src);
     if (status != Success)
         return status;
-
+    else {
     /* CopyRegion needs to be a round trip to make sure the X server
      * queues the swap buffer rendering commands before the DRI client
      * continues rendering.  The reply has a bitmask to signal the
      * presense of optional return values as well, but we're not using
      * that yet.
      */
+        xDRI2CopyRegionReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0
+        };
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
+        WriteToClient(client, sizeof(xDRI2CopyRegionReply), &rep);
 
-    WriteToClient(client, sizeof(xDRI2CopyRegionReply), &rep);
-
-    return Success;
+        return Success;
+    }
 }
 
 static void
@@ -375,7 +382,6 @@ static int
 ProcDRI2SwapBuffers(ClientPtr client)
 {
     REQUEST(xDRI2SwapBuffersReq);
-    xDRI2SwapBuffersReply rep;
     DrawablePtr pDrawable;
     CARD64 target_msc, divisor, remainder, swap_target;
     int status;
@@ -401,15 +407,18 @@ ProcDRI2SwapBuffers(ClientPtr client)
                              &swap_target, DRI2SwapEvent, pDrawable);
     if (status != Success)
         return BadDrawable;
+    else {
+        xDRI2SwapBuffersReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0
+        };
+        load_swap_reply(&rep, swap_target);
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    load_swap_reply(&rep, swap_target);
-
-    WriteToClient(client, sizeof(xDRI2SwapBuffersReply), &rep);
+        WriteToClient(client, sizeof(xDRI2SwapBuffersReply), &rep);
 
-    return Success;
+        return Success;
+    }
 }
 
 static void
@@ -427,7 +436,6 @@ static int
 ProcDRI2GetMSC(ClientPtr client)
 {
     REQUEST(xDRI2GetMSCReq);
-    xDRI2MSCReply rep;
     DrawablePtr pDrawable;
     CARD64 ust, msc, sbc;
     int status;
@@ -441,15 +449,18 @@ ProcDRI2GetMSC(ClientPtr client)
     status = DRI2GetMSC(pDrawable, &ust, &msc, &sbc);
     if (status != Success)
         return status;
+    else {
+        xDRI2MSCReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0
+        };
+        load_msc_reply(&rep, ust, msc, sbc);
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    load_msc_reply(&rep, ust, msc, sbc);
-
-    WriteToClient(client, sizeof(xDRI2MSCReply), &rep);
+        WriteToClient(client, sizeof(xDRI2MSCReply), &rep);
 
-    return Success;
+        return Success;
+    }
 }
 
 static int
@@ -482,11 +493,11 @@ ProcDRI2WaitMSC(ClientPtr client)
 int
 ProcDRI2WaitMSCReply(ClientPtr client, CARD64 ust, CARD64 msc, CARD64 sbc)
 {
-    xDRI2MSCReply rep;
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
+    xDRI2MSCReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
     load_msc_reply(&rep, ust, msc, sbc);
 
     WriteToClient(client, sizeof(xDRI2MSCReply), &rep);
@@ -614,24 +625,26 @@ static int
 SProcDRI2Connect(ClientPtr client)
 {
     REQUEST(xDRI2ConnectReq);
-    xDRI2ConnectReply rep;
 
     /* If the client is swapped, it's not local.  Talk to the hand. */
 
     swaps(&stuff->length);
     if (sizeof(*stuff) / 4 != client->req_len)
         return BadLength;
+    else {
+        xDRI2ConnectReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .driverNameLength = 0,
+            .deviceNameLength = 0
+        };
+        swaps(&rep.sequenceNumber);
 
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    swaps(&rep.sequenceNumber);
-    rep.length = 0;
-    rep.driverNameLength = 0;
-    rep.deviceNameLength = 0;
-
-    WriteToClient(client, sizeof(xDRI2ConnectReply), &rep);
+        WriteToClient(client, sizeof(xDRI2ConnectReply), &rep);
 
-    return Success;
+        return Success;
+    }
 }
 
 static int
-- 
1.7.9.2



More information about the xorg-devel mailing list