[PATCH v2 2/2] Xdmx: removed obsolete remains of __glXActiveScreens variable

Raimonds Cicans ray at apollo.lv
Sun Nov 5 21:29:58 UTC 2017


Variable __glXActiveScreens is defined and used but
_NOT_INITIALIZED_ANYWHERE_. So on some code paths on first use
of this variable Xdmx segfaults.

Signed-off-by: Raimonds Cicans <ray at apollo.lv>
---
 hw/dmx/glxProxy/glxcmds.c     | 13 ++++++-------
 hw/dmx/glxProxy/glxcmdsswap.c | 14 +++++++-------
 hw/dmx/glxProxy/glxcontext.h  |  1 -
 hw/dmx/glxProxy/glxdrawable.h |  2 --
 hw/dmx/glxProxy/glxscreens.c  |  1 -
 hw/dmx/glxProxy/glxscreens.h  | 12 ------------
 hw/dmx/glxProxy/glxserver.h   |  1 -
 hw/dmx/glxProxy/glxvisuals.c  | 26 +++++++++-----------------
 8 files changed, 22 insertions(+), 48 deletions(-)

diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index 1c56a88cb..54d4b2fd4 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -1785,7 +1785,7 @@ CreateGLXPixmap(__GLXclientState * cl,
     ScreenPtr pScreen;
     VisualPtr pVisual;
     __GLXpixmap *pGlxPixmap;
-    __GLXscreenInfo *pGlxScreen;
+    DMXScreenInfo *dmxScreenGlx;
     __GLXvisualConfig *pGlxVisual;
     __GLXFBConfig *pFBConfig;
     int i, s, rc;
@@ -1849,14 +1849,14 @@ CreateGLXPixmap(__GLXclientState * cl,
         /*
          ** Get configuration of the visual.
          */
-        pGlxScreen = &__glXActiveScreens[screenNum];
-        pGlxVisual = pGlxScreen->pGlxVisual;
-        for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
+        dmxScreenGlx = &dmxScreens[screenNum];
+        pGlxVisual = dmxScreenGlx->glxVisuals;
+        for (i = 0; i < dmxScreenGlx->numGlxVisuals; i++, pGlxVisual++) {
             if (pGlxVisual->vid == visual) {
                 break;
             }
         }
-        if (i == pGlxScreen->numVisuals) {
+        if (i == dmxScreenGlx->numGlxVisuals) {
             /*
              ** Visual not support on this screen by this OpenGL implementation.
              */
@@ -1880,7 +1880,7 @@ CreateGLXPixmap(__GLXclientState * cl,
     else {
         pVisual = NULL;
         pGlxVisual = NULL;
-        pGlxScreen = &__glXActiveScreens[pDraw->pScreen->myNum];
+        dmxScreenGlx = &dmxScreens[pDraw->pScreen->myNum];
     }
 
     pGlxPixmap = (__GLXpixmap *) malloc(sizeof(__GLXpixmap));
@@ -1894,7 +1894,6 @@ CreateGLXPixmap(__GLXclientState * cl,
     }
 
     pGlxPixmap->pDraw = pDraw;
-    pGlxPixmap->pGlxScreen = pGlxScreen;
     pGlxPixmap->pGlxVisual = pGlxVisual;
     pGlxPixmap->pFBConfig = pFBConfig;
     pGlxPixmap->pScreen = pScreen;
diff --git a/hw/dmx/glxProxy/glxcmdsswap.c b/hw/dmx/glxProxy/glxcmdsswap.c
index 92ca512a7..ba090a533 100644
--- a/hw/dmx/glxProxy/glxcmdsswap.c
+++ b/hw/dmx/glxProxy/glxcmdsswap.c
@@ -272,7 +272,7 @@ __glXSwapGetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
     ClientPtr client = cl->client;
     xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
     xGLXGetVisualConfigsReply reply;
-    __GLXscreenInfo *pGlxScreen;
+    DMXScreenInfo *dmxScreenGlx;
     __GLXvisualConfig *pGlxVisual;
     CARD32 buf[__GLX_TOTAL_CONFIG];
     unsigned int screen;
@@ -288,14 +288,14 @@ __glXSwapGetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
         client->errorValue = screen;
         return BadValue;
     }
-    pGlxScreen = &__glXActiveScreens[screen];
+    dmxScreenGlx = &dmxScreens[screen];
 
     reply = (xGLXGetVisualConfigsReply) {
         .type = X_Reply,
         .sequenceNumber = client->sequence,
-        .length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 *
+        .length = (dmxScreenGlx->numGlxVisuals * __GLX_SIZE_CARD32 *
                    __GLX_TOTAL_CONFIG) >> 2,
-        .numVisuals = pGlxScreen->numGLXVisuals,
+        .numVisuals = dmxScreenGlx->numGlxVisuals,
         .numProps = __GLX_TOTAL_CONFIG
     };
 
@@ -305,9 +305,9 @@ __glXSwapGetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
     __GLX_SWAP_INT(&reply.numProps);
     WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
 
-    for (i = 0; i < pGlxScreen->numVisuals; i++) {
-        pGlxVisual = &pGlxScreen->pGlxVisual[i];
-        if (!pGlxScreen->isGLXvis[i] || pGlxVisual->vid == 0) {
+    for (i = 0; i < dmxScreenGlx->numGlxVisuals; i++) {
+        pGlxVisual = &dmxScreenGlx->glxVisuals[i];
+        if (pGlxVisual->vid == 0) {
             /* not a usable visual */
             continue;
         }
diff --git a/hw/dmx/glxProxy/glxcontext.h b/hw/dmx/glxProxy/glxcontext.h
index ac8c0573d..a662bbc12 100644
--- a/hw/dmx/glxProxy/glxcontext.h
+++ b/hw/dmx/glxProxy/glxcontext.h
@@ -47,7 +47,6 @@ struct __GLXcontextRec {
      ** when the context is created.
      */
     ScreenPtr pScreen;
-    __GLXscreenInfo *pGlxScreen;
 
     /*
      ** This context is created with respect to this visual.
diff --git a/hw/dmx/glxProxy/glxdrawable.h b/hw/dmx/glxProxy/glxdrawable.h
index 0340896e5..6c1560724 100644
--- a/hw/dmx/glxProxy/glxdrawable.h
+++ b/hw/dmx/glxProxy/glxdrawable.h
@@ -35,7 +35,6 @@ typedef struct {
 
     DrawablePtr pDraw;
     __GLXvisualConfig *pGlxVisual;
-    __GLXscreenInfo *pGlxScreen;
     __GLXFBConfig *pFBConfig;
     ScreenPtr pScreen;
     Bool idExists;
@@ -54,7 +53,6 @@ typedef struct {
 } __glXWindow;
 
 typedef struct {
-    __GLXscreenInfo *pGlxScreen;
     __GLXFBConfig *pFBConfig;
     ScreenPtr pScreen;
     Bool idExists;
diff --git a/hw/dmx/glxProxy/glxscreens.c b/hw/dmx/glxProxy/glxscreens.c
index 508e67ed4..ad0e76f7a 100644
--- a/hw/dmx/glxProxy/glxscreens.c
+++ b/hw/dmx/glxProxy/glxscreens.c
@@ -45,7 +45,6 @@
 #include "panoramiXsrv.h"
 #endif
 
-__GLXscreenInfo *__glXActiveScreens;
 GLint __glXNumActiveScreens;
 
 __GLXFBConfig **__glXFBConfigs;
diff --git a/hw/dmx/glxProxy/glxscreens.h b/hw/dmx/glxProxy/glxscreens.h
index bb7477bc7..a0f8ccaa2 100644
--- a/hw/dmx/glxProxy/glxscreens.h
+++ b/hw/dmx/glxProxy/glxscreens.h
@@ -33,18 +33,6 @@
 
 #include "GL/internal/glcore.h"
 
-typedef struct {
-
-    __GLXvisualConfig *pGlxVisual;
-    GLint numVisuals;
-    GLint numGLXVisuals;
-    GLint *isGLXvis;
-
-    char *GLXvendor;
-    char *GLXextensions;
-
-} __GLXscreenInfo;
-
 extern void __glXScreenInit(GLint);
 extern void __glXScreenReset(void);
 
diff --git a/hw/dmx/glxProxy/glxserver.h b/hw/dmx/glxProxy/glxserver.h
index 7aa5ad2f2..f03389a32 100644
--- a/hw/dmx/glxProxy/glxserver.h
+++ b/hw/dmx/glxProxy/glxserver.h
@@ -73,7 +73,6 @@ typedef struct __GLXcontextRec *GLXContext;
 */
 typedef struct __GLXclientStateRec __GLXclientState;
 
-extern __GLXscreenInfo *__glXActiveScreens;
 extern GLint __glXNumActiveScreens;
 
 /************************************************************************/
diff --git a/hw/dmx/glxProxy/glxvisuals.c b/hw/dmx/glxProxy/glxvisuals.c
index 3fca04f0d..58b0e984a 100644
--- a/hw/dmx/glxProxy/glxvisuals.c
+++ b/hw/dmx/glxProxy/glxvisuals.c
@@ -100,24 +100,20 @@ VisualID
 glxMatchVisualInConfigList(ScreenPtr pScreen, VisualPtr pVisual,
                            __GLXvisualConfig * configs, int nconfigs)
 {
-    __GLXscreenInfo *pGlxScreen;
+    DMXScreenInfo *dmxScreenGlx;
     __GLXvisualConfig *pGlxVisual;
     int i;
 
-    /* check that the glx extension has been initialized */
-    if (!__glXActiveScreens)
-        return 0;
-
-    pGlxScreen = &__glXActiveScreens[pScreen->myNum];
-    pGlxVisual = pGlxScreen->pGlxVisual;
+    dmxScreenGlx = &dmxScreens[pScreen->myNum];
+    pGlxVisual = dmxScreenGlx->glxVisuals;
 
     /* find the glx visual info for pVisual */
-    for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
+    for (i = 0; i < dmxScreenGlx->numGlxVisuals; i++, pGlxVisual++) {
         if (pGlxVisual->vid == pVisual->vid) {
             break;
         }
     }
-    if (i == pGlxScreen->numVisuals) {
+    if (i == dmxScreenGlx->numGlxVisuals) {
         /*
          * the visual is not supported by glx
          */
@@ -130,19 +126,15 @@ glxMatchVisualInConfigList(ScreenPtr pScreen, VisualPtr pVisual,
 VisualPtr
 glxMatchVisual(ScreenPtr pScreen, VisualPtr pVisual, ScreenPtr pMatchScreen)
 {
-    __GLXscreenInfo *pGlxScreen2;
+    DMXScreenInfo *dmxScreenGlx2;
     int j;
     VisualID vid;
 
-    /* check that the glx extension has been initialized */
-    if (!__glXActiveScreens)
-        return NULL;
-
-    pGlxScreen2 = &__glXActiveScreens[pMatchScreen->myNum];
+    dmxScreenGlx2 = &dmxScreens[pMatchScreen->myNum];
 
     vid = glxMatchVisualInConfigList(pScreen, pVisual,
-                                     pGlxScreen2->pGlxVisual,
-                                     pGlxScreen2->numVisuals);
+                                     dmxScreenGlx2->glxVisuals,
+                                     dmxScreenGlx2->numGlxVisuals);
     if (vid) {
         /*
          * find the X visual of the matching glx visual
-- 
2.13.6



More information about the xorg-devel mailing list