[PATCH 04/19] Use C99 designated initializers in dix Replies

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


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 dix/devices.c   |  200 ++++++++++++++++++++-------------------
 dix/dispatch.c  |  279 +++++++++++++++++++++++++++++--------------------------
 dix/dixfonts.c  |   27 +++---
 dix/events.c    |   94 +++++++++++--------
 dix/extension.c |   29 +++---
 dix/property.c  |  145 ++++++++++++++++-------------
 dix/selection.c |   26 +++---
 7 files changed, 426 insertions(+), 374 deletions(-)

diff --git a/dix/devices.c b/dix/devices.c
index ba84608..bde1e14 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1650,7 +1650,6 @@ BadDeviceMap(BYTE * buff, int length, unsigned low, unsigned high, XID *errval)
 int
 ProcSetModifierMapping(ClientPtr client)
 {
-    xSetModifierMappingReply rep;
     int rc;
 
     REQUEST(xSetModifierMappingReq);
@@ -1660,10 +1659,6 @@ ProcSetModifierMapping(ClientPtr client)
                             bytes_to_int32(sizeof(xSetModifierMappingReq))))
         return BadLength;
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
     rc = change_modmap(client, PickKeyboard(client), (KeyCode *) &stuff[1],
                        stuff->numKeyPerModifier);
     if (rc == MappingFailed || rc == -1)
@@ -1671,17 +1666,21 @@ ProcSetModifierMapping(ClientPtr client)
     if (rc != Success && rc != MappingSuccess && rc != MappingFailed &&
         rc != MappingBusy)
         return rc;
-
-    rep.success = rc;
-
-    WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep);
-    return Success;
+    else {
+        xSetModifierMappingReply rep = {
+            .type = X_Reply,
+            .success = rc,
+            .sequenceNumber = client->sequence,
+            .length = 0
+        };
+        WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep);
+        return Success;
+    }
 }
 
 int
 ProcGetModifierMapping(ClientPtr client)
 {
-    xGetModifierMappingReply rep;
     int max_keys_per_mod = 0;
     KeyCode *modkeymap = NULL;
 
@@ -1690,14 +1689,17 @@ ProcGetModifierMapping(ClientPtr client)
     generate_modkeymap(client, PickKeyboard(client), &modkeymap,
                        &max_keys_per_mod);
 
-    memset(&rep, 0, sizeof(xGetModifierMappingReply));
-    rep.type = X_Reply;
-    rep.numKeyPerModifier = max_keys_per_mod;
-    rep.sequenceNumber = client->sequence;
+    {
+        xGetModifierMappingReply rep = {
+            .type = X_Reply,
+            .numKeyPerModifier = max_keys_per_mod,
+            .sequenceNumber = client->sequence,
     /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */
-    rep.length = max_keys_per_mod << 1;
+            .length = max_keys_per_mod << 1
+        };
 
-    WriteReplyToClient(client, sizeof(xGetModifierMappingReply), &rep);
+        WriteReplyToClient(client, sizeof(xGetModifierMappingReply), &rep);
+    }
     WriteToClient(client, max_keys_per_mod * 8, modkeymap);
 
     free(modkeymap);
@@ -1771,7 +1773,6 @@ ProcSetPointerMapping(ClientPtr client)
     int ret;
     int i, j;
     DeviceIntPtr ptr = PickPointer(client);
-    xSetPointerMappingReply rep;
 
     REQUEST(xSetPointerMappingReq);
     REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
@@ -1779,10 +1780,6 @@ ProcSetPointerMapping(ClientPtr client)
     if (client->req_len !=
         bytes_to_int32(sizeof(xSetPointerMappingReq) + stuff->nElts))
         return BadLength;
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.success = MappingSuccess;
     map = (BYTE *) &stuff[1];
 
     /* So we're bounded here by the number of core buttons.  This check
@@ -1808,21 +1805,26 @@ ProcSetPointerMapping(ClientPtr client)
     }
 
     ret = ApplyPointerMapping(ptr, map, stuff->nElts, client);
-    if (ret == MappingBusy)
-        rep.success = ret;
-    else if (ret == -1)
+    if (ret == -1)
         return BadValue;
-    else if (ret != Success)
+    else if ((ret != Success) && (ret != MappingBusy))
         return ret;
-
-    WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
-    return Success;
+    else {
+        xSetPointerMappingReply rep = {
+            .type = X_Reply,
+            .success = (ret == MappingBusy) ? MappingBusy : MappingSuccess,
+            .sequenceNumber = client->sequence,
+            .length = 0
+        };
+
+        WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
+        return Success;
+    }
 }
 
 int
 ProcGetKeyboardMapping(ClientPtr client)
 {
-    xGetKeyboardMappingReply rep;
     DeviceIntPtr kbd = PickKeyboard(client);
     XkbDescPtr xkb;
     KeySymsPtr syms;
@@ -1850,14 +1852,16 @@ ProcGetKeyboardMapping(ClientPtr client)
     syms = XkbGetCoreMap(kbd);
     if (!syms)
         return BadAlloc;
-
-    memset(&rep, 0, sizeof(xGetKeyboardMappingReply));
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.keySymsPerKeyCode = syms->mapWidth;
-    /* length is a count of 4 byte quantities and KeySyms are 4 bytes */
-    rep.length = syms->mapWidth * stuff->count;
-    WriteReplyToClient(client, sizeof(xGetKeyboardMappingReply), &rep);
+    else {
+        xGetKeyboardMappingReply rep = {
+            .type = X_Reply,
+            .keySymsPerKeyCode = syms->mapWidth,
+            .sequenceNumber = client->sequence,
+        /* length is a count of 4 byte quantities and KeySyms are 4 bytes */
+            .length = syms->mapWidth * stuff->count
+        };
+        WriteReplyToClient(client, sizeof(xGetKeyboardMappingReply), &rep);
+    }
     client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
     WriteSwappedDataToClient(client,
                              syms->mapWidth * stuff->count * sizeof(KeySym),
@@ -1872,8 +1876,6 @@ ProcGetKeyboardMapping(ClientPtr client)
 int
 ProcGetPointerMapping(ClientPtr client)
 {
-    xGetPointerMappingReply rep;
-
     /* Apps may get different values each time they call GetPointerMapping as
      * the ClientPointer could change. */
     DeviceIntPtr ptr = PickPointer(client);
@@ -1885,15 +1887,18 @@ ProcGetPointerMapping(ClientPtr client)
     rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess);
     if (rc != Success)
         return rc;
-
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.nElts = (butc) ? butc->numButtons : 0;
-    rep.length = ((unsigned) rep.nElts + (4 - 1)) / 4;
-    WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep);
-    if (butc)
-        WriteToClient(client, (int) rep.nElts, &butc->map[1]);
-    return Success;
+    else {
+        xGetPointerMappingReply rep = {
+            .type = X_Reply,
+            .nElts = (butc) ? butc->numButtons : 0,
+            .sequenceNumber = client->sequence,
+            .length = ((unsigned) rep.nElts + (4 - 1)) / 4
+        };
+        WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep);
+        if (butc)
+            WriteToClient(client, (int) rep.nElts, &butc->map[1]);
+        return Success;
+    }
 }
 
 void
@@ -2130,27 +2135,29 @@ ProcGetKeyboardControl(ClientPtr client)
     int rc, i;
     DeviceIntPtr kbd = PickKeyboard(client);
     KeybdCtrl *ctrl = &kbd->kbdfeed->ctrl;
-    xGetKeyboardControlReply rep;
 
     REQUEST_SIZE_MATCH(xReq);
 
     rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess);
     if (rc != Success)
         return rc;
-
-    rep.type = X_Reply;
-    rep.length = 5;
-    rep.sequenceNumber = client->sequence;
-    rep.globalAutoRepeat = ctrl->autoRepeat;
-    rep.keyClickPercent = ctrl->click;
-    rep.bellPercent = ctrl->bell;
-    rep.bellPitch = ctrl->bell_pitch;
-    rep.bellDuration = ctrl->bell_duration;
-    rep.ledMask = ctrl->leds;
-    for (i = 0; i < 32; i++)
-        rep.map[i] = ctrl->autoRepeats[i];
-    WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep);
-    return Success;
+    else {
+        xGetKeyboardControlReply rep = {
+            .type = X_Reply,
+            .globalAutoRepeat = ctrl->autoRepeat,
+            .sequenceNumber = client->sequence,
+            .length = 5,
+            .ledMask = ctrl->leds,
+            .keyClickPercent = ctrl->click,
+            .bellPercent = ctrl->bell,
+            .bellPitch = ctrl->bell_pitch,
+            .bellDuration = ctrl->bell_duration
+        };
+        for (i = 0; i < 32; i++)
+            rep.map[i] = ctrl->autoRepeats[i];
+        WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep);
+        return Success;
+    }
 }
 
 int
@@ -2272,7 +2279,6 @@ ProcGetPointerControl(ClientPtr client)
 {
     DeviceIntPtr ptr = PickPointer(client);
     PtrCtrl *ctrl = &ptr->ptrfeed->ctrl;
-    xGetPointerControlReply rep;
     int rc;
 
     REQUEST_SIZE_MATCH(xReq);
@@ -2280,15 +2286,18 @@ ProcGetPointerControl(ClientPtr client)
     rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess);
     if (rc != Success)
         return rc;
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.threshold = ctrl->threshold;
-    rep.accelNumerator = ctrl->num;
-    rep.accelDenominator = ctrl->den;
-    WriteReplyToClient(client, sizeof(xGenericReply), &rep);
-    return Success;
+    else {
+        xGetPointerControlReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .accelNumerator = ctrl->num,
+            .accelDenominator = ctrl->den,
+            .threshold = ctrl->threshold
+        };
+        WriteReplyToClient(client, sizeof(xGenericReply), &rep);
+        return Success;
+    }
 }
 
 void
@@ -2312,7 +2321,6 @@ ProcGetMotionEvents(ClientPtr client)
 {
     WindowPtr pWin;
     xTimecoord *coords = (xTimecoord *) NULL;
-    xGetMotionEventsReply rep;
     int i, count, xmin, xmax, ymin, ymax, rc;
     unsigned long nEvents;
     DeviceIntPtr mouse = PickPointer(client);
@@ -2330,8 +2338,6 @@ ProcGetMotionEvents(ClientPtr client)
 
     if (mouse->valuator->motionHintWindow)
         MaybeStopHint(mouse, client);
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
     nEvents = 0;
     start = ClientTimeToServerTime(stuff->start);
     stop = ClientTimeToServerTime(stuff->stop);
@@ -2358,9 +2364,15 @@ ProcGetMotionEvents(ClientPtr client)
                 nEvents++;
             }
     }
-    rep.length = nEvents * bytes_to_int32(sizeof(xTimecoord));
-    rep.nEvents = nEvents;
-    WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep);
+    {
+        xGetMotionEventsReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = nEvents * bytes_to_int32(sizeof(xTimecoord)),
+            .nEvents = nEvents
+        };
+        WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep);
+    }
     if (nEvents) {
         client->pSwapReplyFunc = (ReplySwapPtr) SwapTimeCoordWrite;
         WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord),
@@ -2373,29 +2385,29 @@ ProcGetMotionEvents(ClientPtr client)
 int
 ProcQueryKeymap(ClientPtr client)
 {
-    xQueryKeymapReply rep;
     int rc, i;
     DeviceIntPtr keybd = PickKeyboard(client);
     CARD8 *down = keybd->key->down;
 
     REQUEST_SIZE_MATCH(xReq);
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 2;
 
     rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess);
     if (rc != Success && rc != BadAccess)
         return rc;
-
-    for (i = 0; i < 32; i++)
-        rep.map[i] = down[i];
-
-    if (rc == BadAccess)
-        memset(rep.map, 0, 32);
-
-    WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep);
-
-    return Success;
+    else {
+        xQueryKeymapReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 2
+        };
+        /* If access was denied, leave keymap empty; otherwise send it back */
+        if (rc == Success)
+            for (i = 0; i < 32; i++)
+                rep.map[i] = down[i];
+
+        WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep);
+        return Success;
+    }
 }
 
 /**
diff --git a/dix/dispatch.c b/dix/dispatch.c
index a472227..73b22dd 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -683,17 +683,19 @@ ProcGetWindowAttributes(ClientPtr client)
     WindowPtr pWin;
 
     REQUEST(xResourceReq);
-    xGetWindowAttributesReply wa;
     int rc;
 
     REQUEST_SIZE_MATCH(xResourceReq);
     rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
     if (rc != Success)
         return rc;
-    memset(&wa, 0, sizeof(xGetWindowAttributesReply));
-    GetWindowAttributes(pWin, client, &wa);
-    WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa);
-    return Success;
+    else {
+        xGetWindowAttributesReply wa = { .type = X_Reply };
+
+        GetWindowAttributes(pWin, client, &wa);
+        WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa);
+        return Success;
+    }
 }
 
 int
@@ -926,10 +928,9 @@ GetGeometry(ClientPtr client, xGetGeometryReply * rep)
 int
 ProcGetGeometry(ClientPtr client)
 {
-    xGetGeometryReply rep;
+    xGetGeometryReply rep = { .type = X_Reply };
     int status;
 
-    memset(&rep, 0, sizeof(xGetGeometryReply));
     if ((status = GetGeometry(client, &rep)) != Success)
         return status;
 
@@ -951,14 +952,13 @@ ProcQueryTree(ClientPtr client)
     rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
     if (rc != Success)
         return rc;
-    memset(&reply, 0, sizeof(xQueryTreeReply));
-    reply.type = X_Reply;
-    reply.root = pWin->drawable.pScreen->root->drawable.id;
-    reply.sequenceNumber = client->sequence;
-    if (pWin->parent)
-        reply.parent = pWin->parent->drawable.id;
-    else
-        reply.parent = (Window) None;
+
+    reply = (xQueryTreeReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .root = pWin->drawable.pScreen->root->drawable.id,
+        .parent = (pWin->parent) ? pWin->parent->drawable.id : (Window) None
+    };
     pHead = RealChildHead(pWin);
     for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
         numChildren++;
@@ -1003,13 +1003,12 @@ ProcInternAtom(ClientPtr client)
     tchar = (char *) &stuff[1];
     atom = MakeAtom(tchar, stuff->nbytes, !stuff->onlyIfExists);
     if (atom != BAD_RESOURCE) {
-        xInternAtomReply reply;
-
-        memset(&reply, 0, sizeof(xInternAtomReply));
-        reply.type = X_Reply;
-        reply.length = 0;
-        reply.sequenceNumber = client->sequence;
-        reply.atom = atom;
+        xInternAtomReply reply = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .atom = atom
+        };
         WriteReplyToClient(client, sizeof(xInternAtomReply), &reply);
         return Success;
     }
@@ -1021,19 +1020,19 @@ int
 ProcGetAtomName(ClientPtr client)
 {
     const char *str;
-    xGetAtomNameReply reply;
-    int len;
 
     REQUEST(xResourceReq);
 
     REQUEST_SIZE_MATCH(xResourceReq);
     if ((str = NameForAtom(stuff->id))) {
-        len = strlen(str);
-        memset(&reply, 0, sizeof(xGetAtomNameReply));
-        reply.type = X_Reply;
-        reply.length = bytes_to_int32(len);
-        reply.sequenceNumber = client->sequence;
-        reply.nameLength = len;
+        int len = strlen(str);
+        xGetAtomNameReply reply = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = bytes_to_int32(len),
+            .nameLength = len
+        };
+
         WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply);
         WriteToClient(client, len, str);
         return Success;
@@ -1123,10 +1122,12 @@ ProcTranslateCoords(ClientPtr client)
     rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixGetAttrAccess);
     if (rc != Success)
         return rc;
-    memset(&rep, 0, sizeof(xTranslateCoordsReply));
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
+
+    rep = (xTranslateCoordsReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
     if (!SAME_SCREENS(pWin->drawable, pDst->drawable)) {
         rep.sameScreen = xFalse;
         rep.child = None;
@@ -1266,7 +1267,6 @@ ProcQueryFont(ClientPtr client)
 int
 ProcQueryTextExtents(ClientPtr client)
 {
-    xQueryTextExtentsReply reply;
     FontPtr pFont;
     ExtentInfoRec info;
     unsigned long length;
@@ -1288,19 +1288,23 @@ ProcQueryTextExtents(ClientPtr client)
     }
     if (!QueryTextExtents(pFont, length, (unsigned char *) &stuff[1], &info))
         return BadAlloc;
-    reply.type = X_Reply;
-    reply.length = 0;
-    reply.sequenceNumber = client->sequence;
-    reply.drawDirection = info.drawDirection;
-    reply.fontAscent = info.fontAscent;
-    reply.fontDescent = info.fontDescent;
-    reply.overallAscent = info.overallAscent;
-    reply.overallDescent = info.overallDescent;
-    reply.overallWidth = info.overallWidth;
-    reply.overallLeft = info.overallLeft;
-    reply.overallRight = info.overallRight;
-    WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply);
-    return Success;
+    else {
+        xQueryTextExtentsReply reply = {
+            .type = X_Reply,
+            .drawDirection = info.drawDirection,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .fontAscent = info.fontAscent,
+            .fontDescent = info.fontDescent,
+            .overallAscent = info.overallAscent,
+            .overallDescent = info.overallDescent,
+            .overallWidth = info.overallWidth,
+            .overallLeft = info.overallLeft,
+            .overallRight = info.overallRight
+        };
+        WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply);
+        return Success;
+    }
 }
 
 int
@@ -1981,7 +1985,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
     long widthBytesLine, length;
     Mask plane = 0;
     char *pBuf;
-    xGetImageReply xgi;
+    xGetImageReply xgi = { .type = X_Reply };
     RegionPtr pVisibleRegion = NULL;
 
     if ((format != XYPixmap) && (format != ZPixmap)) {
@@ -1992,8 +1996,6 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
     if (rc != Success)
         return rc;
 
-    memset(&xgi, 0, sizeof(xGetImageReply));
-
     relx = x;
     rely = y;
 
@@ -2051,7 +2053,6 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
         rely < 0 || rely + height > (int) pBoundingDraw->height)
         return BadMatch;
 
-    xgi.type = X_Reply;
     xgi.sequenceNumber = client->sequence;
     xgi.depth = pDraw->depth;
     if (format == ZPixmap) {
@@ -2466,7 +2467,6 @@ ProcAllocColor(ClientPtr client)
 {
     ColormapPtr pmap;
     int rc;
-    xAllocColorReply acr;
 
     REQUEST(xAllocColorReq);
 
@@ -2474,13 +2474,15 @@ ProcAllocColor(ClientPtr client)
     rc = dixLookupResourceByType((pointer *) &pmap, stuff->cmap, RT_COLORMAP,
                                  client, DixAddAccess);
     if (rc == Success) {
-        acr.type = X_Reply;
-        acr.length = 0;
-        acr.sequenceNumber = client->sequence;
-        acr.red = stuff->red;
-        acr.green = stuff->green;
-        acr.blue = stuff->blue;
-        acr.pixel = 0;
+        xAllocColorReply acr = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .red = stuff->red,
+            .green = stuff->green,
+            .blue = stuff->blue,
+            .pixel = 0
+        };
         if ((rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
                              &acr.pixel, client->index)))
             return rc;
@@ -2509,12 +2511,11 @@ ProcAllocNamedColor(ClientPtr client)
     rc = dixLookupResourceByType((pointer *) &pcmp, stuff->cmap, RT_COLORMAP,
                                  client, DixAddAccess);
     if (rc == Success) {
-        xAllocNamedColorReply ancr;
-
-        ancr.type = X_Reply;
-        ancr.length = 0;
-        ancr.sequenceNumber = client->sequence;
-
+        xAllocNamedColorReply ancr = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0
+        };
         if (OsLookupColor
             (pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes,
              &ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue)) {
@@ -2555,7 +2556,6 @@ ProcAllocColorCells(ClientPtr client)
     rc = dixLookupResourceByType((pointer *) &pcmp, stuff->cmap, RT_COLORMAP,
                                  client, DixAddAccess);
     if (rc == Success) {
-        xAllocColorCellsReply accr;
         int npixels, nmasks;
         long length;
         Pixel *ppixels, *pmasks;
@@ -2585,11 +2585,13 @@ ProcAllocColorCells(ClientPtr client)
         if (noPanoramiXExtension || !pcmp->pScreen->myNum)
 #endif
         {
-            accr.type = X_Reply;
-            accr.length = bytes_to_int32(length);
-            accr.sequenceNumber = client->sequence;
-            accr.nPixels = npixels;
-            accr.nMasks = nmasks;
+            xAllocColorCellsReply accr = {
+                .type = X_Reply,
+                .sequenceNumber = client->sequence,
+                .length = bytes_to_int32(length),
+                .nPixels = npixels,
+                .nMasks = nmasks
+            };
             WriteReplyToClient(client, sizeof(xAllocColorCellsReply), &accr);
             client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
             WriteSwappedDataToClient(client, length, ppixels);
@@ -2615,7 +2617,7 @@ ProcAllocColorPlanes(ClientPtr client)
     rc = dixLookupResourceByType((pointer *) &pcmp, stuff->cmap, RT_COLORMAP,
                                  client, DixAddAccess);
     if (rc == Success) {
-        xAllocColorPlanesReply acpr;
+        xAllocColorPlanesReply acpr = { .type = X_Reply };
         int npixels;
         long length;
         Pixel *ppixels;
@@ -2629,7 +2631,6 @@ ProcAllocColorPlanes(ClientPtr client)
             client->errorValue = stuff->contiguous;
             return BadValue;
         }
-        acpr.type = X_Reply;
         acpr.sequenceNumber = client->sequence;
         acpr.nPixels = npixels;
         length = (long) npixels *sizeof(Pixel);
@@ -2757,7 +2758,6 @@ ProcQueryColors(ClientPtr client)
     if (rc == Success) {
         int count;
         xrgb *prgbs;
-        xQueryColorsReply qcr;
 
         count =
             bytes_to_int32((client->req_len << 2) - sizeof(xQueryColorsReq));
@@ -2769,12 +2769,15 @@ ProcQueryColors(ClientPtr client)
             free(prgbs);
             return rc;
         }
-        memset(&qcr, 0, sizeof(xQueryColorsReply));
-        qcr.type = X_Reply;
-        qcr.length = bytes_to_int32(count * sizeof(xrgb));
-        qcr.sequenceNumber = client->sequence;
-        qcr.nColors = count;
-        WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
+        else {
+            xQueryColorsReply qcr = {
+                .type = X_Reply,
+                .sequenceNumber = client->sequence,
+                .length = bytes_to_int32(count * sizeof(xrgb)),
+                .nColors = count
+            };
+            WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
+        }
         if (count) {
             client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend;
             WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs);
@@ -2801,17 +2804,22 @@ ProcLookupColor(ClientPtr client)
     rc = dixLookupResourceByType((pointer *) &pcmp, stuff->cmap, RT_COLORMAP,
                                  client, DixReadAccess);
     if (rc == Success) {
-        xLookupColorReply lcr;
+        CARD16 exactRed, exactGreen, exactBlue;
 
         if (OsLookupColor
             (pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes,
-             &lcr.exactRed, &lcr.exactGreen, &lcr.exactBlue)) {
-            lcr.type = X_Reply;
-            lcr.length = 0;
-            lcr.sequenceNumber = client->sequence;
-            lcr.screenRed = lcr.exactRed;
-            lcr.screenGreen = lcr.exactGreen;
-            lcr.screenBlue = lcr.exactBlue;
+             &exactRed, &exactGreen, &exactBlue)) {
+            xLookupColorReply lcr = {
+                .type = X_Reply,
+                .sequenceNumber = client->sequence,
+                .length = 0,
+                .exactRed = exactRed,
+                .exactGreen = exactGreen,
+                .exactBlue = exactBlue,
+                .screenRed = exactRed,
+                .screenGreen = exactGreen,
+                .screenBlue = exactBlue
+            };
             (*pcmp->pScreen->ResolveColor) (&lcr.screenRed,
                                             &lcr.screenGreen,
                                             &lcr.screenBlue, pcmp->pVisual);
@@ -2965,7 +2973,6 @@ ProcFreeCursor(ClientPtr client)
 int
 ProcQueryBestSize(ClientPtr client)
 {
-    xQueryBestSizeReply reply;
     DrawablePtr pDraw;
     ScreenPtr pScreen;
     int rc;
@@ -2991,13 +2998,16 @@ ProcQueryBestSize(ClientPtr client)
         return rc;
     (*pScreen->QueryBestSize) (stuff->class, &stuff->width,
                                &stuff->height, pScreen);
-    memset(&reply, 0, sizeof(xQueryBestSizeReply));
-    reply.type = X_Reply;
-    reply.length = 0;
-    reply.sequenceNumber = client->sequence;
-    reply.width = stuff->width;
-    reply.height = stuff->height;
-    WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply);
+    {
+        xQueryBestSizeReply reply = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .width = stuff->width,
+            .height = stuff->height
+        };
+        WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply);
+    }
     return Success;
 }
 
@@ -3064,7 +3074,6 @@ ProcSetScreenSaver(ClientPtr client)
 int
 ProcGetScreenSaver(ClientPtr client)
 {
-    xGetScreenSaverReply rep;
     int rc, i;
 
     REQUEST_SIZE_MATCH(xReq);
@@ -3076,14 +3085,18 @@ ProcGetScreenSaver(ClientPtr client)
             return rc;
     }
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.timeout = ScreenSaverTime / MILLI_PER_SECOND;
-    rep.interval = ScreenSaverInterval / MILLI_PER_SECOND;
-    rep.preferBlanking = ScreenSaverBlanking;
-    rep.allowExposures = ScreenSaverAllowExposures;
-    WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep);
+    {
+        xGetScreenSaverReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .timeout = ScreenSaverTime / MILLI_PER_SECOND,
+            .interval = ScreenSaverInterval / MILLI_PER_SECOND,
+            .preferBlanking = ScreenSaverBlanking,
+            .allowExposures = ScreenSaverAllowExposures
+        };
+        WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep);
+    }
     return Success;
 }
 
@@ -3107,9 +3120,9 @@ ProcChangeHosts(ClientPtr client)
 int
 ProcListHosts(ClientPtr client)
 {
-    xListHostsReply reply;
     int len, nHosts, result;
     pointer pdata;
+    BOOL enabled;
 
     /* REQUEST(xListHostsReq); */
 
@@ -3120,20 +3133,25 @@ ProcListHosts(ClientPtr client)
     if (result != Success)
         return result;
 
-    result = GetHosts(&pdata, &nHosts, &len, &reply.enabled);
+    result = GetHosts(&pdata, &nHosts, &len, &enabled);
     if (result != Success)
         return result;
-    reply.type = X_Reply;
-    reply.sequenceNumber = client->sequence;
-    reply.nHosts = nHosts;
-    reply.length = bytes_to_int32(len);
-    WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
-    if (nHosts) {
-        client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend;
-        WriteSwappedDataToClient(client, len, pdata);
-    }
-    free(pdata);
-    return Success;
+    else {
+        xListHostsReply reply = {
+            .type = X_Reply,
+            .enabled = enabled,
+            .sequenceNumber = client->sequence,
+            .length = bytes_to_int32(len),
+            .nHosts = nHosts
+        };
+        WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
+        if (nHosts) {
+            client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend;
+            WriteSwappedDataToClient(client, len, pdata);
+        }
+        free(pdata);
+        return Success;
+    }
 }
 
 int
@@ -3230,7 +3248,6 @@ ProcSetFontPath(ClientPtr client)
 int
 ProcGetFontPath(ClientPtr client)
 {
-    xGetFontPathReply reply;
     int rc, stringLens, numpaths;
     unsigned char *bufferStart;
 
@@ -3240,16 +3257,18 @@ ProcGetFontPath(ClientPtr client)
     rc = GetFontPath(client, &numpaths, &stringLens, &bufferStart);
     if (rc != Success)
         return rc;
-
-    reply.type = X_Reply;
-    reply.sequenceNumber = client->sequence;
-    reply.length = bytes_to_int32(stringLens + numpaths);
-    reply.nPaths = numpaths;
-
-    WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
-    if (stringLens || numpaths)
-        WriteToClient(client, stringLens + numpaths, bufferStart);
-    return Success;
+    else {
+        xGetFontPathReply reply = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = bytes_to_int32(stringLens + numpaths),
+            .nPaths = numpaths
+        };
+        WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
+        if (stringLens || numpaths)
+            WriteToClient(client, stringLens + numpaths, bufferStart);
+        return Success;
+    }
 }
 
 int
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index beac4d2..5cbfb05 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -753,11 +753,12 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
     for (i = 0; i < nnames; i++)
         stringLens += (names->length[i] <= 255) ? names->length[i] : 0;
 
-    memset(&reply, 0, sizeof(xListFontsReply));
-    reply.type = X_Reply;
-    reply.length = bytes_to_int32(stringLens + nnames);
-    reply.nFonts = nnames;
-    reply.sequenceNumber = client->sequence;
+    reply = (xListFontsReply) {
+        .type = X_Reply,
+        .length = bytes_to_int32(stringLens + nnames),
+        .nFonts = nnames,
+        .sequenceNumber = client->sequence
+    };
 
     bufptr = bufferStart = malloc(reply.length << 2);
 
@@ -863,7 +864,6 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
     xFontProp *pFP;
     int i;
     int aliascount = 0;
-    xListFontsWithInfoReply finalReply;
 
     if (client->clientGone) {
         if (c->current.current_fpe < c->num_fpes) {
@@ -1030,12 +1030,15 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
     }
  finish:
     length = sizeof(xListFontsWithInfoReply);
-    memset((char *) &finalReply, 0, sizeof(xListFontsWithInfoReply));
-    finalReply.type = X_Reply;
-    finalReply.sequenceNumber = client->sequence;
-    finalReply.length = bytes_to_int32(sizeof(xListFontsWithInfoReply)
-                                       - sizeof(xGenericReply));
-    WriteSwappedDataToClient(client, length, &finalReply);
+    {
+        xListFontsWithInfoReply finalReply = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = bytes_to_int32(sizeof(xListFontsWithInfoReply)
+                                       - sizeof(xGenericReply))
+        };
+        WriteSwappedDataToClient(client, length, &finalReply);
+    }
  bail:
     ClientWakeup(client);
  xinerama_sleep:
diff --git a/dix/events.c b/dix/events.c
index dbfe9d9..7192341 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4753,7 +4753,6 @@ int
 ProcGetInputFocus(ClientPtr client)
 {
     DeviceIntPtr kbd = PickKeyboard(client);
-    xGetInputFocusReply rep;
     FocusClassPtr focus = kbd->focus;
     int rc;
 
@@ -4763,20 +4762,24 @@ ProcGetInputFocus(ClientPtr client)
     rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetFocusAccess);
     if (rc != Success)
         return rc;
+    else {
+        xGetInputFocusReply rep = {
+            .type = X_Reply,
+            .length = 0,
+            .sequenceNumber = client->sequence,
+            .revertTo = focus->revert
+        };
+
+        if (focus->win == NoneWin)
+            rep.focus = None;
+        else if (focus->win == PointerRootWin)
+            rep.focus = PointerRoot;
+        else
+            rep.focus = focus->win->drawable.id;
 
-    memset(&rep, 0, sizeof(xGetInputFocusReply));
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    if (focus->win == NoneWin)
-        rep.focus = None;
-    else if (focus->win == PointerRootWin)
-        rep.focus = PointerRoot;
-    else
-        rep.focus = focus->win->drawable.id;
-    rep.revertTo = focus->revert;
-    WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep);
-    return Success;
+        WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep);
+        return Success;
+    }
 }
 
 /**
@@ -4788,7 +4791,7 @@ ProcGetInputFocus(ClientPtr client)
 int
 ProcGrabPointer(ClientPtr client)
 {
-    xGrabPointerReply rep;
+    BYTE status;
     DeviceIntPtr device = PickPointer(client);
     GrabPtr grab;
     GrabMask mask;
@@ -4815,7 +4818,6 @@ ProcGrabPointer(ClientPtr client)
             return rc;
     }
 
-    memset(&rep, 0, sizeof(xGrabPointerReply));
     oldCursor = NullCursor;
     grab = device->deviceGrab.grab;
 
@@ -4830,18 +4832,23 @@ ProcGrabPointer(ClientPtr client)
 
     rc = GrabDevice(client, device, stuff->pointerMode, stuff->keyboardMode,
                     stuff->grabWindow, stuff->ownerEvents, stuff->time,
-                    &mask, CORE, stuff->cursor, stuff->confineTo, &rep.status);
+                    &mask, CORE, stuff->cursor, stuff->confineTo, &status);
     if (rc != Success)
         return rc;
+    else {
+        xGrabPointerReply rep = {
+            .type = X_Reply,
+            .status = status,
+            .sequenceNumber = client->sequence,
+            .length = 0
+        };
 
-    if (oldCursor && rep.status == GrabSuccess)
-        FreeCursor(oldCursor, (Cursor) 0);
+        if (oldCursor && status == GrabSuccess)
+            FreeCursor(oldCursor, (Cursor) 0);
 
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 0;
-    WriteReplyToClient(client, sizeof(xGrabPointerReply), &rep);
-    return Success;
+        WriteReplyToClient(client, sizeof(xGrabPointerReply), &rep);
+        return Success;
+    }
 }
 
 /**
@@ -5055,7 +5062,7 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
 int
 ProcGrabKeyboard(ClientPtr client)
 {
-    xGrabKeyboardReply rep;
+    BYTE status;
 
     REQUEST(xGrabKeyboardReq);
     int result;
@@ -5064,21 +5071,25 @@ ProcGrabKeyboard(ClientPtr client)
 
     REQUEST_SIZE_MATCH(xGrabKeyboardReq);
 
-    memset(&rep, 0, sizeof(xGrabKeyboardReply));
     mask.core = KeyPressMask | KeyReleaseMask;
 
     result = GrabDevice(client, keyboard, stuff->pointerMode,
                         stuff->keyboardMode, stuff->grabWindow,
                         stuff->ownerEvents, stuff->time, &mask, CORE, None,
-                        None, &rep.status);
+                        None, &status);
 
     if (result != Success)
         return result;
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 0;
-    WriteReplyToClient(client, sizeof(xGrabKeyboardReply), &rep);
-    return Success;
+    else {
+        xGrabKeyboardReply rep = {
+            .type = X_Reply,
+            .status = status,
+            .sequenceNumber = client->sequence,
+            .length = 0
+        };
+        WriteReplyToClient(client, sizeof(xGrabKeyboardReply), &rep);
+        return Success;
+    }
 }
 
 /**
@@ -5139,15 +5150,16 @@ ProcQueryPointer(ClientPtr client)
     pSprite = mouse->spriteInfo->sprite;
     if (mouse->valuator->motionHintWindow)
         MaybeStopHint(mouse, client);
-    memset(&rep, 0, sizeof(xQueryPointerReply));
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.mask = event_get_corestate(mouse, keyboard);
-    rep.length = 0;
-    rep.root = (GetCurrentRootWindow(mouse))->drawable.id;
-    rep.rootX = pSprite->hot.x;
-    rep.rootY = pSprite->hot.y;
-    rep.child = None;
+    rep = (xQueryPointerReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .mask = event_get_corestate(mouse, keyboard),
+        .root = (GetCurrentRootWindow(mouse))->drawable.id,
+        .rootX = pSprite->hot.x,
+        .rootY = pSprite->hot.y,
+        .child = None
+    };
     if (pSprite->hot.pScreen == pWin->drawable.pScreen) {
         rep.sameScreen = xTrue;
         rep.winX = pSprite->hot.x - pWin->drawable.x;
diff --git a/dix/extension.c b/dix/extension.c
index 3cdfb51..b6fcc98 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -245,19 +245,18 @@ CloseDownExtensions(void)
 int
 ProcQueryExtension(ClientPtr client)
 {
-    xQueryExtensionReply reply;
+    xQueryExtensionReply reply = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .major_opcode = 0
+    };
     int i;
 
     REQUEST(xQueryExtensionReq);
 
     REQUEST_FIXED_SIZE(xQueryExtensionReq, stuff->nbytes);
 
-    memset(&reply, 0, sizeof(xQueryExtensionReply));
-    reply.type = X_Reply;
-    reply.length = 0;
-    reply.major_opcode = 0;
-    reply.sequenceNumber = client->sequence;
-
     if (!NumExtensions)
         reply.present = xFalse;
     else {
@@ -278,19 +277,17 @@ ProcQueryExtension(ClientPtr client)
 int
 ProcListExtensions(ClientPtr client)
 {
-    xListExtensionsReply reply;
-    char *bufptr, *buffer;
+    xListExtensionsReply reply = {
+        .type = X_Reply,
+        .nExtensions = 0,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
+    char *bufptr, *buffer = NULL;
     int total_length = 0;
 
     REQUEST_SIZE_MATCH(xReq);
 
-    memset(&reply, 0, sizeof(xListExtensionsReply));
-    reply.type = X_Reply;
-    reply.nExtensions = 0;
-    reply.length = 0;
-    reply.sequenceNumber = client->sequence;
-    buffer = NULL;
-
     if (NumExtensions) {
         int i, j;
 
diff --git a/dix/property.c b/dix/property.c
index b1b8312..fcc2c64 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -413,15 +413,18 @@ DeleteAllWindowProperties(WindowPtr pWin)
 }
 
 static int
-NullPropertyReply(ClientPtr client,
-                  ATOM propertyType, int format, xGetPropertyReply * reply)
+NullPropertyReply(ClientPtr client, ATOM propertyType, int format)
 {
-    reply->nItems = 0;
-    reply->length = 0;
-    reply->bytesAfter = 0;
-    reply->propertyType = propertyType;
-    reply->format = format;
-    WriteReplyToClient(client, sizeof(xGenericReply), reply);
+    xGetPropertyReply reply = {
+        .type = X_Reply,
+        .format = format,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .propertyType = propertyType,
+        .bytesAfter = 0,
+        .nItems = 0
+    };
+    WriteReplyToClient(client, sizeof(xGenericReply), &reply);
     return Success;
 }
 
@@ -439,10 +442,9 @@ int
 ProcGetProperty(ClientPtr client)
 {
     PropertyPtr pProp, prevProp;
-    unsigned long n, len, ind;
+    unsigned long n, ind;
     int rc;
     WindowPtr pWin;
-    xGetPropertyReply reply;
     Mask win_mode = DixGetPropAccess, prop_mode = DixReadAccess;
 
     REQUEST(xGetPropertyReq);
@@ -470,13 +472,9 @@ ProcGetProperty(ClientPtr client)
         return BadAtom;
     }
 
-    memset(&reply, 0, sizeof(xGetPropertyReply));
-    reply.type = X_Reply;
-    reply.sequenceNumber = client->sequence;
-
     rc = dixLookupProperty(&pProp, pWin, stuff->property, client, prop_mode);
     if (rc == BadMatch)
-        return NullPropertyReply(client, None, 0, &reply);
+        return NullPropertyReply(client, None, 0);
     else if (rc != Success)
         return rc;
 
@@ -485,11 +483,15 @@ ProcGetProperty(ClientPtr client)
 
     if (((stuff->type != pProp->type) && (stuff->type != AnyPropertyType))
         ) {
-        reply.bytesAfter = pProp->size;
-        reply.format = pProp->format;
-        reply.length = 0;
-        reply.nItems = 0;
-        reply.propertyType = pProp->type;
+        xGetPropertyReply reply = {
+            .type = X_Reply,
+            .format = pProp->format,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .propertyType = pProp->type,
+            .bytesAfter = pProp->size,
+            .nItems = 0
+        };
         WriteReplyToClient(client, sizeof(xGenericReply), &reply);
         return Success;
     }
@@ -507,60 +509,65 @@ ProcGetProperty(ClientPtr client)
         client->errorValue = stuff->longOffset;
         return BadValue;
     }
+    else {
+        unsigned long len = min(n - ind, 4 * stuff->longLength);
+        xGetPropertyReply reply = {
+            .type = X_Reply,
+            .format = pProp->format,
+            .sequenceNumber = client->sequence,
+            .length = bytes_to_int32(len),
+            .propertyType = pProp->type,
+            .bytesAfter = n - (ind + len),
+            .nItems = len / (pProp->format / 8)
+        };
+
+        if (stuff->delete && (reply.bytesAfter == 0))
+            deliverPropertyNotifyEvent(pWin, PropertyDelete,
+                                       pProp->propertyName);
 
-    len = min(n - ind, 4 * stuff->longLength);
-
-    reply.bytesAfter = n - (ind + len);
-    reply.format = pProp->format;
-    reply.length = bytes_to_int32(len);
-    reply.nItems = len / (pProp->format / 8);
-    reply.propertyType = pProp->type;
-
-    if (stuff->delete && (reply.bytesAfter == 0))
-        deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
+        WriteReplyToClient(client, sizeof(xGenericReply), &reply);
 
-    WriteReplyToClient(client, sizeof(xGenericReply), &reply);
-    if (len) {
-        switch (reply.format) {
-        case 32:
-            client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
-            break;
-        case 16:
-            client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write;
-            break;
-        default:
-            client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient;
-            break;
+        if (len) {
+            switch (reply.format) {
+            case 32:
+                client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
+                break;
+            case 16:
+                client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write;
+                break;
+            default:
+                client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient;
+                break;
+            }
+            WriteSwappedDataToClient(client, len, (char *) pProp->data + ind);
         }
-        WriteSwappedDataToClient(client, len, (char *) pProp->data + ind);
-    }
 
-    if (stuff->delete && (reply.bytesAfter == 0)) {
-        /* Delete the Property */
-        if (pWin->optional->userProps == pProp) {
-            /* Takes care of head */
-            if (!(pWin->optional->userProps = pProp->next))
-                CheckWindowOptionalNeed(pWin);
-        }
-        else {
-            /* Need to traverse to find the previous element */
-            prevProp = pWin->optional->userProps;
-            while (prevProp->next != pProp)
-                prevProp = prevProp->next;
-            prevProp->next = pProp->next;
-        }
+        if (stuff->delete && (reply.bytesAfter == 0)) {
+            /* Delete the Property */
+            if (pWin->optional->userProps == pProp) {
+                /* Takes care of head */
+                if (!(pWin->optional->userProps = pProp->next))
+                    CheckWindowOptionalNeed(pWin);
+            }
+            else {
+                /* Need to traverse to find the previous element */
+                prevProp = pWin->optional->userProps;
+                while (prevProp->next != pProp)
+                    prevProp = prevProp->next;
+                prevProp->next = pProp->next;
+            }
 
-        free(pProp->data);
-        dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
+            free(pProp->data);
+            dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
+        }
+        return Success;
     }
-    return Success;
 }
 
 int
 ProcListProperties(ClientPtr client)
 {
     Atom *pAtoms = NULL, *temppAtoms;
-    xListPropertiesReply xlpr;
     int rc, numProps = 0;
     WindowPtr pWin;
     PropertyPtr pProp, realProp;
@@ -589,11 +596,15 @@ ProcListProperties(ClientPtr client)
         }
     }
 
-    xlpr.type = X_Reply;
-    xlpr.nProperties = numProps;
-    xlpr.length = bytes_to_int32(numProps * sizeof(Atom));
-    xlpr.sequenceNumber = client->sequence;
-    WriteReplyToClient(client, sizeof(xGenericReply), &xlpr);
+    {
+        xListPropertiesReply xlpr = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = bytes_to_int32(numProps * sizeof(Atom)),
+            .nProperties = numProps
+        };
+        WriteReplyToClient(client, sizeof(xGenericReply), &xlpr);
+    }
     if (numProps) {
         client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
         WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
diff --git a/dix/selection.c b/dix/selection.c
index dfdcfdc..59d4871 100644
--- a/dix/selection.c
+++ b/dix/selection.c
@@ -228,7 +228,6 @@ ProcGetSelectionOwner(ClientPtr client)
 {
     int rc;
     Selection *pSel;
-    xGetSelectionOwnerReply reply;
 
     REQUEST(xResourceReq);
     REQUEST_SIZE_MATCH(xResourceReq);
@@ -238,21 +237,20 @@ ProcGetSelectionOwner(ClientPtr client)
         return BadAtom;
     }
 
-    memset(&reply, 0, sizeof(xGetSelectionOwnerReply));
-    reply.type = X_Reply;
-    reply.length = 0;
-    reply.sequenceNumber = client->sequence;
-
     rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess);
-    if (rc == Success)
-        reply.owner = pSel->window;
-    else if (rc == BadMatch)
-        reply.owner = None;
-    else
+    if (rc != Success && rc != BadMatch)
         return rc;
-
-    WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply);
-    return Success;
+    else {
+        xGetSelectionOwnerReply reply = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .owner = (rc == Success) ? pSel->window : None
+        };
+
+        WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply);
+        return Success;
+    }
 }
 
 int
-- 
1.7.9.2



More information about the xorg-devel mailing list