[PATCH 3/6] xf86: make xf86DeleteScreen take a ScrnInfoPtr

Dave Airlie airlied at gmail.com
Wed May 23 09:07:15 PDT 2012


From: Dave Airlie <airlied at redhat.com>

stop passing indices into this function.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 hw/xfree86/common/xf86.h       |    2 +-
 hw/xfree86/common/xf86Bus.c    |    2 +-
 hw/xfree86/common/xf86Helper.c |   10 ++++------
 hw/xfree86/common/xf86Init.c   |    2 +-
 4 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 991659d..53d3df3 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -249,7 +249,7 @@ extern _X_EXPORT void xf86AddDriver(DriverPtr driver, pointer module,
                                     int flags);
 extern _X_EXPORT void xf86DeleteDriver(int drvIndex);
 extern _X_EXPORT ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags);
-extern _X_EXPORT void xf86DeleteScreen(int scrnIndex, int flags);
+extern _X_EXPORT void xf86DeleteScreen(ScrnInfoPtr pScrn, int flags);
 extern _X_EXPORT int xf86AllocateScrnInfoPrivateIndex(void);
 extern _X_EXPORT Bool xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp,
                                        int pad);
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 733fe84..da18650 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -185,7 +185,7 @@ xf86BusConfig(void)
             xf86Msg(X_ERROR,
                     "Screen %d deleted because of no matching config section.\n",
                     i);
-            xf86DeleteScreen(i--, 0);
+            xf86DeleteScreen(xf86Screens[i--], 0);
         }
     }
 
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index a05edf4..5efca09 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -198,21 +198,19 @@ xf86AllocateScreen(DriverPtr drv, int flags)
  */
 
 void
-xf86DeleteScreen(int scrnIndex, int flags)
+xf86DeleteScreen(ScrnInfoPtr pScrn, int flags)
 {
-    ScrnInfoPtr pScrn;
     int i;
+    int scrnIndex;
 
     /* First check if the screen is valid */
     if (xf86NumScreens == 0 || xf86Screens == NULL)
         return;
 
-    if (scrnIndex > xf86NumScreens - 1)
-        return;
-
-    if (!(pScrn = xf86Screens[scrnIndex]))
+    if (!pScrn)
         return;
 
+    scrnIndex = pScrn->scrnIndex;
     /* If a FreeScreen function is defined, call it here */
     if (pScrn->FreeScreen != NULL)
         pScrn->FreeScreen(pScrn, 0);
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 46e2245..ff15f9e 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -591,7 +591,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
         }
         for (i = 0; i < xf86NumScreens; i++)
             if (!xf86Screens[i]->configured)
-                xf86DeleteScreen(i--, 0);
+                xf86DeleteScreen(xf86Screens[i--], 0);
 
         /*
          * If no screens left, return now.
-- 
1.7.6



More information about the xorg-devel mailing list