[PATCH v2 13/29] Use C99 designated initializers in dix Replies

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


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 dix/devices.c   |  102 +++++++++++++++-----------
 dix/dispatch.c  |  214 +++++++++++++++++++++++++++++--------------------------
 dix/dixfonts.c  |   22 +++---
 dix/events.c    |   54 +++++++-------
 dix/extension.c |   22 +++---
 dix/property.c  |   62 ++++++++--------
 dix/selection.c |    9 +--
 7 files changed, 265 insertions(+), 220 deletions(-)

diff --git a/dix/devices.c b/dix/devices.c
index b2cc594..dc99abc 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1660,9 +1660,11 @@ ProcSetModifierMapping(ClientPtr client)
                             bytes_to_int32(sizeof(xSetModifierMappingReq))))
         return BadLength;
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
+    rep = (xSetModifierMappingReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
 
     rc = change_modmap(client, PickKeyboard(client), (KeyCode *) &stuff[1],
                        stuff->numKeyPerModifier);
@@ -1690,12 +1692,13 @@ 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;
+    rep = (xGetModifierMappingReply) {
+        .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);
     WriteToClient(client, max_keys_per_mod * 8, modkeymap);
@@ -1779,10 +1782,13 @@ 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;
+
+    rep = (xSetPointerMappingReply) {
+        .type = X_Reply,
+        .success = MappingSuccess,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
     map = (BYTE *) &stuff[1];
 
     /* So we're bounded here by the number of core buttons.  This check
@@ -1851,12 +1857,13 @@ ProcGetKeyboardMapping(ClientPtr client)
     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;
+    rep = (xGetKeyboardMappingReply) {
+        .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,
@@ -1886,10 +1893,12 @@ ProcGetPointerMapping(ClientPtr client)
     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;
+    rep = (xGetPointerMappingReply) {
+        .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]);
@@ -2138,15 +2147,17 @@ ProcGetKeyboardControl(ClientPtr client)
     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;
+    rep = (xGetKeyboardControlReply) {
+        .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);
@@ -2281,12 +2292,14 @@ ProcGetPointerControl(ClientPtr client)
     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;
+    rep = (xGetPointerControlReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .accelNumerator = ctrl->num,
+        .accelDenominator = ctrl->den,
+        .threshold = ctrl->threshold
+    };
     WriteReplyToClient(client, sizeof(xGenericReply), &rep);
     return Success;
 }
@@ -2330,8 +2343,10 @@ ProcGetMotionEvents(ClientPtr client)
 
     if (mouse->valuator->motionHintWindow)
         MaybeStopHint(mouse, client);
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
+    rep = (xGetMotionEventsReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence
+    };
     nEvents = 0;
     start = ClientTimeToServerTime(stuff->start);
     stop = ClientTimeToServerTime(stuff->stop);
@@ -2379,10 +2394,11 @@ ProcQueryKeymap(ClientPtr client)
     CARD8 *down = keybd->key->down;
 
     REQUEST_SIZE_MATCH(xReq);
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 2;
-    memset(rep.map, 0, 32);
+    rep = (xQueryKeymapReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 2
+    };
 
     rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess);
     /* If rc is Success, we're allowed to copy out the keymap.
diff --git a/dix/dispatch.c b/dix/dispatch.c
index b707f57..a3cf63e 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -926,10 +926,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 +950,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 +1001,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 +1018,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 +1120,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;
@@ -1288,17 +1287,19 @@ 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;
+    reply = (xQueryTextExtentsReply) {
+        .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;
 }
@@ -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);
@@ -2629,9 +2631,11 @@ ProcAllocColorPlanes(ClientPtr client)
             client->errorValue = stuff->contiguous;
             return BadValue;
         }
-        acpr.type = X_Reply;
-        acpr.sequenceNumber = client->sequence;
-        acpr.nPixels = npixels;
+        acpr = (xAllocColorPlanesReply) {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .nPixels = npixels
+        };
         length = (long) npixels *sizeof(Pixel);
 
         ppixels = malloc(length);
@@ -2769,11 +2773,12 @@ 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;
+        qcr = (xQueryColorsReply) {
+            .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;
@@ -2806,16 +2811,17 @@ ProcLookupColor(ClientPtr client)
         if (OsLookupColor
             (pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes,
              &exactRed, &exactGreen, &exactBlue)) {
-            xLookupColorReply lcr;
-            lcr.type = X_Reply;
-            lcr.length = 0;
-            lcr.sequenceNumber = client->sequence;
-            lcr.exactRed = exactRed;
-            lcr.exactGreen = exactGreen;
-            lcr.exactBlue = exactBlue;
-            lcr.screenRed = exactRed;
-            lcr.screenGreen = exactGreen;
-            lcr.screenBlue = 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);
@@ -2995,12 +3001,13 @@ 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;
+    reply = (xQueryBestSizeReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .width = stuff->width,
+        .height = stuff->height
+    };
     WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply);
     return Success;
 }
@@ -3080,13 +3087,15 @@ 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;
+    rep = (xGetScreenSaverReply) {
+        .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;
 }
@@ -3128,11 +3137,14 @@ ProcListHosts(ClientPtr client)
     result = GetHosts(&pdata, &nHosts, &len, &enabled);
     if (result != Success)
         return result;
-    reply.type = X_Reply;
-    reply.enabled = enabled;
-    reply.sequenceNumber = client->sequence;
-    reply.nHosts = nHosts;
-    reply.length = bytes_to_int32(len);
+
+    reply = (xListHostsReply) {
+        .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;
@@ -3247,10 +3259,12 @@ ProcGetFontPath(ClientPtr client)
     if (rc != Success)
         return rc;
 
-    reply.type = X_Reply;
-    reply.sequenceNumber = client->sequence;
-    reply.length = bytes_to_int32(stringLens + numpaths);
-    reply.nPaths = numpaths;
+    reply = (xGetFontPathReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = bytes_to_int32(stringLens + numpaths),
+        .nPaths = numpaths
+    };
 
     WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
     if (stringLens || numpaths)
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index d1f6326..ad21860 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);
 
@@ -1030,11 +1031,12 @@ 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));
+    finalReply = (xListFontsWithInfoReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = bytes_to_int32(sizeof(xListFontsWithInfoReply)
+                                 - sizeof(xGenericReply))
+    };
     WriteSwappedDataToClient(client, length, &finalReply);
  bail:
     ClientWakeup(client);
diff --git a/dix/events.c b/dix/events.c
index c5eceec..1708710 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4767,17 +4767,20 @@ ProcGetInputFocus(ClientPtr client)
     if (rc != Success)
         return rc;
 
-    memset(&rep, 0, sizeof(xGetInputFocusReply));
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
+    rep = (xGetInputFocusReply) {
+        .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;
-    rep.revertTo = focus->revert;
+
     WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep);
     return Success;
 }
@@ -4840,11 +4843,12 @@ ProcGrabPointer(ClientPtr client)
     if (oldCursor && status == GrabSuccess)
         FreeCursor(oldCursor, (Cursor) 0);
 
-    memset(&rep, 0, sizeof(xGrabPointerReply));
-    rep.type = X_Reply;
-    rep.status = status;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 0;
+    rep = (xGrabPointerReply) {
+        .type = X_Reply,
+        .status = status,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
     WriteReplyToClient(client, sizeof(xGrabPointerReply), &rep);
     return Success;
 }
@@ -5080,11 +5084,12 @@ ProcGrabKeyboard(ClientPtr client)
     if (result != Success)
         return result;
 
-    memset(&rep, 0, sizeof(xGrabKeyboardReply));
-    rep.type = X_Reply;
-    rep.status = status;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 0;
+    rep = (xGrabKeyboardReply) {
+        .type = X_Reply,
+        .status = status,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
     WriteReplyToClient(client, sizeof(xGrabKeyboardReply), &rep);
     return Success;
 }
@@ -5147,15 +5152,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..6380db3 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -252,11 +252,12 @@ ProcQueryExtension(ClientPtr client)
 
     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;
+    reply = (xQueryExtensionReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+        .major_opcode = 0
+    };
 
     if (!NumExtensions)
         reply.present = xFalse;
@@ -284,11 +285,12 @@ ProcListExtensions(ClientPtr client)
 
     REQUEST_SIZE_MATCH(xReq);
 
-    memset(&reply, 0, sizeof(xListExtensionsReply));
-    reply.type = X_Reply;
-    reply.nExtensions = 0;
-    reply.length = 0;
-    reply.sequenceNumber = client->sequence;
+    reply = (xListExtensionsReply) {
+        .type = X_Reply,
+        .nExtensions = 0,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
     buffer = NULL;
 
     if (NumExtensions) {
diff --git a/dix/property.c b/dix/property.c
index 5ef97ee..5aa6f4a 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -415,15 +415,15 @@ DeleteAllWindowProperties(WindowPtr pWin)
 static int
 NullPropertyReply(ClientPtr client, ATOM propertyType, int format)
 {
-    xGetPropertyReply reply;
-    memset(&reply, 0, sizeof(xGetPropertyReply));
-    reply.type = X_Reply;
-    reply.sequenceNumber = client->sequence;
-    reply.nItems = 0;
-    reply.length = 0;
-    reply.bytesAfter = 0;
-    reply.propertyType = propertyType;
-    reply.format = format;
+    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;
 }
@@ -484,14 +484,15 @@ ProcGetProperty(ClientPtr client)
 
     if (((stuff->type != pProp->type) && (stuff->type != AnyPropertyType))
         ) {
-        memset(&reply, 0, sizeof(xGetPropertyReply));
-        reply.type = X_Reply;
-        reply.sequenceNumber = client->sequence;
-        reply.bytesAfter = pProp->size;
-        reply.format = pProp->format;
-        reply.length = 0;
-        reply.nItems = 0;
-        reply.propertyType = pProp->type;
+        reply = (xGetPropertyReply) {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .bytesAfter = pProp->size,
+            .format = pProp->format,
+            .length = 0,
+            .nItems = 0,
+            .propertyType = pProp->type
+        };
         WriteReplyToClient(client, sizeof(xGenericReply), &reply);
         return Success;
     }
@@ -512,14 +513,15 @@ ProcGetProperty(ClientPtr client)
 
     len = min(n - ind, 4 * stuff->longLength);
 
-    memset(&reply, 0, sizeof(xGetPropertyReply));
-    reply.type = X_Reply;
-    reply.sequenceNumber = client->sequence;
-    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;
+    reply = (xGetPropertyReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .bytesAfter = n - (ind + len),
+        .format = pProp->format,
+        .length = bytes_to_int32(len),
+        .nItems = len / (pProp->format / 8),
+        .propertyType = pProp->type
+    };
 
     if (stuff->delete && (reply.bytesAfter == 0))
         deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
@@ -594,10 +596,12 @@ ProcListProperties(ClientPtr client)
         }
     }
 
-    xlpr.type = X_Reply;
-    xlpr.nProperties = numProps;
-    xlpr.length = bytes_to_int32(numProps * sizeof(Atom));
-    xlpr.sequenceNumber = client->sequence;
+    xlpr = (xListPropertiesReply) {
+        .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;
diff --git a/dix/selection.c b/dix/selection.c
index dfdcfdc..80b5893 100644
--- a/dix/selection.c
+++ b/dix/selection.c
@@ -238,10 +238,11 @@ ProcGetSelectionOwner(ClientPtr client)
         return BadAtom;
     }
 
-    memset(&reply, 0, sizeof(xGetSelectionOwnerReply));
-    reply.type = X_Reply;
-    reply.length = 0;
-    reply.sequenceNumber = client->sequence;
+    reply = (xGetSelectionOwnerReply) {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+    };
 
     rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess);
     if (rc == Success)
-- 
1.7.9.2



More information about the xorg-devel mailing list