[PATCH 12/19] Use C99 designated initializers in Xephyr Replies

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


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 hw/kdrive/ephyr/ephyrdriext.c |  297 +++++++++++++++++++++--------------------
 hw/kdrive/ephyr/ephyrglxext.c |  240 +++++++++++++++++----------------
 2 files changed, 280 insertions(+), 257 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
index aefbcfb..28a90e4 100644
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ b/hw/kdrive/ephyr/ephyrdriext.c
@@ -517,18 +517,19 @@ EphyrMirrorHostVisuals(ScreenPtr a_screen)
 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);
 
     EPHYR_LOG("enter\n");
 
-    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);
@@ -544,7 +545,6 @@ ProcXF86DRIQueryVersion(register ClientPtr client)
 static int
 ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
 {
-    xXF86DRIQueryDirectRenderingCapableReply rep;
     Bool isCapable;
 
     REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
@@ -555,35 +555,36 @@ ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
         client->errorValue = stuff->screen;
         return BadValue;
     }
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
     if (!ephyrDRIQueryDirectRenderingCapable(stuff->screen, &isCapable)) {
         return BadValue;
     }
-    rep.isCapable = isCapable;
+    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 (!LocalClient(client) || client->swapped)
-        rep.isCapable = 0;
+        WriteToClient(client, sizeof(xXF86DRIQueryDirectRenderingCapableReply),
+                      &rep);
+        EPHYR_LOG("leave\n");
 
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber);
-        swapl(&rep.length);
+        return Success;
     }
-
-    WriteToClient(client, sizeof(xXF86DRIQueryDirectRenderingCapableReply),
-                  &rep);
-    EPHYR_LOG("leave\n");
-
-    return Success;
 }
 
 static int
 ProcXF86DRIOpenConnection(register ClientPtr client)
 {
-    xXF86DRIOpenConnectionReply rep;
     drm_handle_t hSAREA;
     char *busIdString = NULL;
 
@@ -599,37 +600,35 @@ ProcXF86DRIOpenConnection(register ClientPtr client)
     if (!ephyrDRIOpenConnection(stuff->screen, &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)),
+            .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
+            .busIdStringLength = busIdStringLength
+        };
 
-    WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), &rep);
-    if (rep.busIdStringLength)
-        WriteToClient(client, rep.busIdStringLength, busIdString);
-    free(busIdString);
-    EPHYR_LOG("leave\n");
-    return Success;
+        WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), &rep);
+        if (busIdStringLength)
+            WriteToClient(client, busIdStringLength, busIdString);
+        free(busIdString);
+        EPHYR_LOG("leave\n");
+        return Success;
+    }
 }
 
 static int
 ProcXF86DRIAuthConnection(register ClientPtr client)
 {
-    xXF86DRIAuthConnectionReply rep;
-
     REQUEST(xXF86DRIAuthConnectionReq);
     REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
 
@@ -638,19 +637,22 @@ ProcXF86DRIAuthConnection(register ClientPtr client)
         client->errorValue = stuff->screen;
         return BadValue;
     }
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.authenticated = 1;
-
-    if (!ephyrDRIAuthConnection(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 (!ephyrDRIAuthConnection(stuff->screen, stuff->magic)) {
+            ErrorF("Failed to authenticate %lu\n", (unsigned long) stuff->magic);
+            rep.authenticated = 0;
+        }
+        WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), &rep);
+        EPHYR_LOG("leave\n");
+        return Success;
     }
-    WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), &rep);
-    EPHYR_LOG("leave\n");
-    return Success;
 }
 
 static int
@@ -675,9 +677,6 @@ ProcXF86DRICloseConnection(register ClientPtr client)
 static int
 ProcXF86DRIGetClientDriverName(register ClientPtr client)
 {
-    xXF86DRIGetClientDriverNameReply rep;
-    char *clientDriverName;
-
     REQUEST(xXF86DRIGetClientDriverNameReq);
     REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
 
@@ -686,37 +685,42 @@ ProcXF86DRIGetClientDriverName(register ClientPtr client)
         client->errorValue = stuff->screen;
         return BadValue;
     }
+    else {
+        xXF86DRIGetClientDriverNameReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence
+        };
+        char *clientDriverName = NULL;
+
+        ephyrDRIGetClientDriverName(stuff->screen,
+                                    (int *) &rep.ddxDriverMajorVersion,
+                                    (int *) &rep.ddxDriverMinorVersion,
+                                    (int *) &rep.ddxDriverPatchVersion,
+                                    &clientDriverName);
+
+        if (clientDriverName)
+            rep.clientDriverNameLength = strlen(clientDriverName);
+        else
+            rep.clientDriverNameLength = 0;
+
+        rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) -
+                                    SIZEOF(xGenericReply) +
+                                    pad_to_int32(rep.clientDriverNameLength));
 
-    ephyrDRIGetClientDriverName(stuff->screen,
-                                (int *) &rep.ddxDriverMajorVersion,
-                                (int *) &rep.ddxDriverMinorVersion,
-                                (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) -
-                                SIZEOF(xGenericReply) +
-                                pad_to_int32(rep.clientDriverNameLength));
-
-    WriteToClient(client, sizeof(xXF86DRIGetClientDriverNameReply), &rep);
-    if (rep.clientDriverNameLength)
-        WriteToClient(client, rep.clientDriverNameLength, clientDriverName);
-    EPHYR_LOG("leave\n");
-    return Success;
+        WriteToClient(client, sizeof(xXF86DRIGetClientDriverNameReply), &rep);
+        if (rep.clientDriverNameLength)
+            WriteToClient(client, rep.clientDriverNameLength, clientDriverName);
+        EPHYR_LOG("leave\n");
+        return Success;
+    }
 }
 
 static int
 ProcXF86DRICreateContext(register ClientPtr client)
 {
-    xXF86DRICreateContextReply rep;
     ScreenPtr pScreen;
     VisualPtr visual;
     int i = 0;
-    unsigned long context_id = 0;
 
     REQUEST(xXF86DRICreateContextReq);
     REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
@@ -727,10 +731,6 @@ ProcXF86DRICreateContext(register ClientPtr client)
         return BadValue;
     }
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
     pScreen = screenInfo.screens[stuff->screen];
     visual = pScreen->visuals;
 
@@ -742,16 +742,25 @@ ProcXF86DRICreateContext(register ClientPtr client)
         /* No visual found */
         return BadValue;
     }
+    else {
+        unsigned long context_id = stuff->context;
+        drm_context_t hHWContext;
 
-    context_id = stuff->context;
-    if (!ephyrDRICreateContext(stuff->screen,
-                               stuff->visual,
-                               &context_id,
-                               (drm_context_t *) & rep.hHWContext)) {
-        return BadValue;
+        if (!ephyrDRICreateContext(stuff->screen, stuff->visual,
+                                   &context_id, &hHWContext)) {
+            return BadValue;
+        }
+        else {
+            xXF86DRICreateContextReply rep = {
+                .type = X_Reply,
+                .sequenceNumber = client->sequence,
+                .length = 0,
+                .hHWContext = hHWContext
+            };
+
+            WriteToClient(client, sizeof(xXF86DRICreateContextReply), &rep);
+        }
     }
-
-    WriteToClient(client, sizeof(xXF86DRICreateContextReply), &rep);
     EPHYR_LOG("leave\n");
     return Success;
 }
@@ -915,7 +924,7 @@ destroyHostPeerWindow(const WindowPtr a_win)
 static int
 ProcXF86DRICreateDrawable(ClientPtr client)
 {
-    xXF86DRICreateDrawableReply rep;
+    drm_drawable_t hHWDrawable;
     DrawablePtr drawable = NULL;
     WindowPtr window = NULL;
     EphyrWindowPair *pair = NULL;
@@ -931,10 +940,6 @@ ProcXF86DRICreateDrawable(ClientPtr client)
         return BadValue;
     }
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
     rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0,
                            DixReadAccess);
     if (rc != Success)
@@ -955,9 +960,7 @@ ProcXF86DRICreateDrawable(ClientPtr client)
         return BadAlloc;
     }
 
-    if (!ephyrDRICreateDrawable(stuff->screen,
-                                remote_win,
-                                (drm_drawable_t *) & rep.hHWDrawable)) {
+    if (!ephyrDRICreateDrawable(stuff->screen, remote_win, &hHWDrawable)) {
         EPHYR_LOG_ERROR("failed to create dri drawable\n");
         return BadValue;
     }
@@ -973,7 +976,16 @@ ProcXF86DRICreateDrawable(ClientPtr client)
         EPHYR_LOG("paired window '%p' with remote '%d'\n", window, remote_win);
     }
 
-    WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), &rep);
+    {
+        xXF86DRICreateDrawableReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .hHWDrawable = hHWDrawable
+        };
+
+        WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), &rep);
+    }
     EPHYR_LOG("leave\n");
     return Success;
 }
@@ -1023,7 +1035,11 @@ ProcXF86DRIDestroyDrawable(register ClientPtr client)
 static int
 ProcXF86DRIGetDrawableInfo(register ClientPtr client)
 {
-    xXF86DRIGetDrawableInfoReply rep;
+    xXF86DRIGetDrawableInfoReply rep = {
+        .type = X_Reply,
+        .sequenceNumber = client->sequence,
+        .length = 0
+    };
     DrawablePtr drawable;
     WindowPtr window = NULL;
     EphyrWindowPair *pair = NULL;
@@ -1035,16 +1051,11 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client)
     REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
 
     EPHYR_LOG("enter\n");
-    memset(&rep, 0, sizeof(rep));
     if (stuff->screen >= screenInfo.numScreens) {
         client->errorValue = stuff->screen;
         return BadValue;
     }
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
     rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0,
                            DixReadAccess);
     if (rc != Success || !drawable) {
@@ -1159,10 +1170,6 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client)
 static int
 ProcXF86DRIGetDeviceInfo(register ClientPtr client)
 {
-    xXF86DRIGetDeviceInfoReply rep;
-    drm_handle_t hFrameBuffer;
-    void *pDevPrivate;
-
     REQUEST(xXF86DRIGetDeviceInfoReq);
     REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
 
@@ -1171,40 +1178,44 @@ ProcXF86DRIGetDeviceInfo(register ClientPtr client)
         client->errorValue = stuff->screen;
         return BadValue;
     }
+    else {
+        xXF86DRIGetDeviceInfoReply rep = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0
+        };
+        drm_handle_t hFrameBuffer;
+        void *pDevPrivate;
+
+        if (!ephyrDRIGetDeviceInfo(stuff->screen,
+                                   &hFrameBuffer,
+                                   (int *) &rep.framebufferOrigin,
+                                   (int *) &rep.framebufferSize,
+                                   (int *) &rep.framebufferStride,
+                                   (int *) &rep.devPrivateSize, &pDevPrivate)) {
+            return BadValue;
+        }
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    if (!ephyrDRIGetDeviceInfo(stuff->screen,
-                               &hFrameBuffer,
-                               (int *) &rep.framebufferOrigin,
-                               (int *) &rep.framebufferSize,
-                               (int *) &rep.framebufferStride,
-                               (int *) &rep.devPrivateSize, &pDevPrivate)) {
-        return BadValue;
-    }
-
-    rep.hFrameBufferLow = (CARD32) (hFrameBuffer & 0xffffffff);
+        rep.hFrameBufferLow = (CARD32) (hFrameBuffer & 0xffffffff);
 #if defined(LONG64) && !defined(__linux__)
-    rep.hFrameBufferHigh = (CARD32) (hFrameBuffer >> 32);
+        rep.hFrameBufferHigh = (CARD32) (hFrameBuffer >> 32);
 #else
-    rep.hFrameBufferHigh = 0;
+        rep.hFrameBufferHigh = 0;
 #endif
 
-    rep.length = 0;
-    if (rep.devPrivateSize) {
-        rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) -
-                                    SIZEOF(xGenericReply) +
-                                    pad_to_int32(rep.devPrivateSize));
-    }
+        if (rep.devPrivateSize) {
+            rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) -
+                                        SIZEOF(xGenericReply) +
+                                        pad_to_int32(rep.devPrivateSize));
+        }
 
-    WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), &rep);
-    if (rep.length) {
-        WriteToClient(client, rep.devPrivateSize, pDevPrivate);
+        WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), &rep);
+        if (rep.length) {
+            WriteToClient(client, rep.devPrivateSize, pDevPrivate);
+        }
+        EPHYR_LOG("leave\n");
+        return Success;
     }
-    EPHYR_LOG("leave\n");
-    return Success;
 }
 
 static int
diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c
index 1287e04..3eae571 100644
--- a/hw/kdrive/ephyr/ephyrglxext.c
+++ b/hw/kdrive/ephyr/ephyrglxext.c
@@ -145,7 +145,6 @@ ephyrGLXQueryVersion(__GLXclientState * a_cl, GLbyte * a_pc)
 {
     ClientPtr client = a_cl->client;
     xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
-    xGLXQueryVersionReply reply;
     int major, minor;
     int res = BadImplementation;
 
@@ -156,24 +155,28 @@ ephyrGLXQueryVersion(__GLXclientState * a_cl, GLbyte * a_pc)
 
     if (!ephyrHostGLXQueryVersion(&major, &minor)) {
         EPHYR_LOG_ERROR("ephyrHostGLXQueryVersion() failed\n");
-        goto out;
-    }
-    EPHYR_LOG("major:%d, minor:%d\n", major, minor);
-    reply.majorVersion = major;
-    reply.minorVersion = minor;
-    reply.length = 0;
-    reply.type = X_Reply;
-    reply.sequenceNumber = client->sequence;
-
-    if (client->swapped) {
-        __glXSwapQueryVersionReply(client, &reply);
     }
     else {
-        WriteToClient(client, sz_xGLXQueryVersionReply, &reply);
+        xGLXQueryVersionReply reply = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .majorVersion = major,
+            .minorVersion = minor
+        };
+
+        EPHYR_LOG("major:%d, minor:%d\n", major, minor);
+
+        if (client->swapped) {
+            __glXSwapQueryVersionReply(client, &reply);
+        }
+        else {
+            WriteToClient(client, sz_xGLXQueryVersionReply, &reply);
+        }
+
+        res = Success;
     }
 
-    res = Success;
- out:
     EPHYR_LOG("leave\n");
     return res;
 }
@@ -197,7 +200,6 @@ ephyrGLXGetVisualConfigsReal(__GLXclientState * a_cl,
 {
     xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) a_pc;
     ClientPtr client = a_cl->client;
-    xGLXGetVisualConfigsReply reply;
     int32_t *props_buf = NULL, num_visuals = 0,
         num_props = 0, res = BadImplementation, i = 0,
         props_per_visual_size = 0, props_buf_size = 0;
@@ -211,33 +213,35 @@ ephyrGLXGetVisualConfigsReal(__GLXclientState * a_cl,
                                       &num_props,
                                       &props_buf_size, &props_buf)) {
         EPHYR_LOG_ERROR("ephyrHostGLXGetVisualConfigs() failed\n");
-        goto out;
     }
-    EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals, num_props);
-
-    reply.numVisuals = num_visuals;
-    reply.numProps = num_props;
-    reply.length = (num_visuals * __GLX_SIZE_CARD32 * num_props) >> 2;
-    reply.type = X_Reply;
-    reply.sequenceNumber = client->sequence;
-
-    if (a_do_swap) {
-        __GLX_SWAP_SHORT(&reply.sequenceNumber);
-        __GLX_SWAP_INT(&reply.length);
-        __GLX_SWAP_INT(&reply.numVisuals);
-        __GLX_SWAP_INT(&reply.numProps);
-        __GLX_SWAP_INT_ARRAY(props_buf, num_props);
-    }
-    WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
-    props_per_visual_size = props_buf_size / num_visuals;
-    for (i = 0; i < num_visuals; i++) {
-        WriteToClient(client,
-                      props_per_visual_size,
-                      (char *) props_buf + i * props_per_visual_size);
+    else {
+        xGLXGetVisualConfigsReply reply = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = (num_visuals * __GLX_SIZE_CARD32 * num_props) >> 2,
+            .numVisuals = num_visuals,
+            .numProps = num_props
+        };
+
+        EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals, num_props);
+
+        if (a_do_swap) {
+            __GLX_SWAP_SHORT(&reply.sequenceNumber);
+            __GLX_SWAP_INT(&reply.length);
+            __GLX_SWAP_INT(&reply.numVisuals);
+            __GLX_SWAP_INT(&reply.numProps);
+            __GLX_SWAP_INT_ARRAY(props_buf, num_props);
+        }
+        WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
+        props_per_visual_size = props_buf_size / num_visuals;
+        for (i = 0; i < num_visuals; i++) {
+            WriteToClient(client,
+                          props_per_visual_size,
+                          (char *) props_buf + i * props_per_visual_size);
+        }
+        res = Success;
     }
-    res = Success;
 
- out:
     EPHYR_LOG("leave\n");
     free(props_buf);
     props_buf = NULL;
@@ -251,7 +255,6 @@ ephyrGLXGetFBConfigsSGIXReal(__GLXclientState * a_cl,
 {
     xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) a_pc;
     ClientPtr client = a_cl->client;
-    xGLXGetVisualConfigsReply reply;
     int32_t *props_buf = NULL, num_visuals = 0,
         num_props = 0, res = BadImplementation, i = 0,
         props_per_visual_size = 0, props_buf_size = 0;
@@ -265,33 +268,35 @@ ephyrGLXGetFBConfigsSGIXReal(__GLXclientState * a_cl,
                                                 &num_props,
                                                 &props_buf_size, &props_buf)) {
         EPHYR_LOG_ERROR("ephyrHostGLXGetVisualConfigs() failed\n");
-        goto out;
     }
-    EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals, num_props);
-
-    reply.numVisuals = num_visuals;
-    reply.numProps = num_props;
-    reply.length = props_buf_size >> 2;
-    reply.type = X_Reply;
-    reply.sequenceNumber = client->sequence;
-
-    if (a_do_swap) {
-        __GLX_SWAP_SHORT(&reply.sequenceNumber);
-        __GLX_SWAP_INT(&reply.length);
-        __GLX_SWAP_INT(&reply.numVisuals);
-        __GLX_SWAP_INT(&reply.numProps);
-        __GLX_SWAP_INT_ARRAY(props_buf, num_props);
-    }
-    WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
-    props_per_visual_size = props_buf_size / num_visuals;
-    for (i = 0; i < num_visuals; i++) {
-        WriteToClient(client,
-                      props_per_visual_size,
-                      &((char *) props_buf)[i * props_per_visual_size]);
+    else {
+        xGLXGetVisualConfigsReply reply = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = props_buf_size >> 2,
+            .numVisuals = num_visuals,
+            .numProps = num_props
+        };
+
+        EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals, num_props);
+
+        if (a_do_swap) {
+            __GLX_SWAP_SHORT(&reply.sequenceNumber);
+            __GLX_SWAP_INT(&reply.length);
+            __GLX_SWAP_INT(&reply.numVisuals);
+            __GLX_SWAP_INT(&reply.numProps);
+            __GLX_SWAP_INT_ARRAY(props_buf, num_props);
+        }
+        WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
+        props_per_visual_size = props_buf_size / num_visuals;
+        for (i = 0; i < num_visuals; i++) {
+            WriteToClient(client,
+                          props_per_visual_size,
+                          &((char *) props_buf)[i * props_per_visual_size]);
+        }
+        res = Success;
     }
-    res = Success;
 
- out:
     EPHYR_LOG("leave\n");
     free(props_buf);
     props_buf = NULL;
@@ -350,9 +355,7 @@ ephyrGLXQueryServerString(__GLXclientState * a_cl, GLbyte * a_pc)
     int res = BadImplementation;
     ClientPtr client = a_cl->client;
     xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) a_pc;
-    xGLXQueryServerStringReply reply;
-    char *server_string = NULL, *buf = NULL;
-    int length = 0;
+    char *server_string = NULL;
 
     EPHYR_LOG("enter\n");
     if (!ephyrHostGLXGetStringFromServer(req->screen,
@@ -360,34 +363,39 @@ ephyrGLXQueryServerString(__GLXclientState * a_cl, GLbyte * a_pc)
                                          EPHYR_HOST_GLX_QueryServerString,
                                          &server_string)) {
         EPHYR_LOG_ERROR("failed to query string from host\n");
-        goto out;
     }
-    EPHYR_LOG("string: %s\n", server_string);
-    length = strlen(server_string) + 1;
-    reply.type = X_Reply;
-    reply.sequenceNumber = client->sequence;
-    reply.length = __GLX_PAD(length) >> 2;
-    reply.n = length;
-    buf = calloc(reply.length << 2, 1);
-    if (!buf) {
-        EPHYR_LOG_ERROR("failed to allocate string\n;");
-        return BadAlloc;
+    else {
+        int length = strlen(server_string) + 1;
+        xGLXQueryServerStringReply reply = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = __GLX_PAD(length) >> 2,
+            .n = length
+        };
+        char *buf;
+
+        EPHYR_LOG("string: %s\n", server_string);
+
+        buf = calloc(reply.length << 2, 1);
+        if (!buf) {
+            EPHYR_LOG_ERROR("failed to allocate string\n;");
+            return BadAlloc;
+        }
+        memcpy(buf, server_string, length);
+
+        WriteToClient(client, sz_xGLXQueryServerStringReply, &reply);
+        WriteToClient(client, (int) (reply.length << 2), server_string);
+
+        free(buf);
+        buf = NULL;
+
+        res = Success;
     }
-    memcpy(buf, server_string, length);
-
-    WriteToClient(client, sz_xGLXQueryServerStringReply, &reply);
-    WriteToClient(client, (int) (reply.length << 2), server_string);
 
-    res = Success;
-
- out:
     EPHYR_LOG("leave\n");
     free(server_string);
     server_string = NULL;
 
-    free(buf);
-    buf = NULL;
-
     return res;
 }
 
@@ -510,9 +518,9 @@ ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
 {
     int res = BadImplementation;
     xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc;
-    xGLXMakeCurrentReply reply;
     DrawablePtr drawable = NULL;
     int rc = 0;
+    GLXContextTag contextTag = 0;
 
     EPHYR_LOG("enter\n");
     rc = dixLookupDrawable(&drawable,
@@ -521,27 +529,30 @@ ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
     EPHYR_RETURN_VAL_IF_FAIL(drawable->pScreen, BadValue);
     EPHYR_LOG("screen nummber requested:%d\n", drawable->pScreen->myNum);
 
-    memset(&reply, 0, sizeof(reply));
     if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawable->pScreen->myNum),
                                  req->context,
                                  req->oldContextTag,
-                                 (int *) &reply.contextTag)) {
+                                 (int *) &contextTag)) {
         EPHYR_LOG_ERROR("ephyrHostGLXMakeCurrent() failed\n");
-        goto out;
     }
-    reply.length = 0;
-    reply.type = X_Reply;
-    reply.sequenceNumber = a_cl->client->sequence;
-    if (a_do_swap) {
-        __GLX_DECLARE_SWAP_VARIABLES;
-        __GLX_SWAP_SHORT(&reply.sequenceNumber);
-        __GLX_SWAP_INT(&reply.length);
-        __GLX_SWAP_INT(&reply.contextTag);
+    else {
+        xGLXMakeCurrentReply reply = {
+            .type = X_Reply,
+            .sequenceNumber = a_cl->client->sequence,
+            .length = 0,
+            .contextTag = contextTag
+        };
+        if (a_do_swap) {
+            __GLX_DECLARE_SWAP_VARIABLES;
+            __GLX_SWAP_SHORT(&reply.sequenceNumber);
+            __GLX_SWAP_INT(&reply.length);
+            __GLX_SWAP_INT(&reply.contextTag);
+        }
+        WriteToClient(a_cl->client, sz_xGLXMakeCurrentReply, &reply);
+
+        res = Success;
     }
-    WriteToClient(a_cl->client, sz_xGLXMakeCurrentReply, &reply);
 
-    res = Success;
- out:
     EPHYR_LOG("leave\n");
     return res;
 }
@@ -674,26 +685,27 @@ ephyrGLXIsDirectReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
     int res = BadImplementation;
     ClientPtr client = a_cl->client;
     xGLXIsDirectReq *req = (xGLXIsDirectReq *) a_pc;
-    xGLXIsDirectReply reply;
     int is_direct = 0;
 
     EPHYR_RETURN_VAL_IF_FAIL(a_cl && a_pc, FALSE);
 
     EPHYR_LOG("enter\n");
 
-    memset(&reply, 0, sizeof(reply));
     if (!ephyrHostIsContextDirect(req->context, (int *) &is_direct)) {
         EPHYR_LOG_ERROR("ephyrHostIsContextDirect() failed\n");
-        goto out;
     }
-    reply.isDirect = is_direct;
-    reply.length = 0;
-    reply.type = X_Reply;
-    reply.sequenceNumber = client->sequence;
-    WriteToClient(client, sz_xGLXIsDirectReply, &reply);
-    res = Success;
+    else {
+        xGLXIsDirectReply reply = {
+            .type = X_Reply,
+            .sequenceNumber = client->sequence,
+            .length = 0,
+            .isDirect = is_direct
+        };
+
+        WriteToClient(client, sz_xGLXIsDirectReply, &reply);
+        res = Success;
+    }
 
- out:
     EPHYR_LOG("leave\n");
     return res;
 }
-- 
1.7.9.2



More information about the xorg-devel mailing list