[xserver-commit] xserver/dix main.c,3.42,3.43

Jaymz Julian xserver-commit@pdx.freedesktop.org


Committed by: jaymz

Update of /cvs/xserver/xserver/dix
In directory pdx:/tmp/cvs-serv21951/dix

Modified Files:
	main.c 
Log Message:
I like cows.  and NULL checks.



Index: main.c
===================================================================
RCS file: /cvs/xserver/xserver/dix/main.c,v
retrieving revision 3.42
retrieving revision 3.43
diff -u -d -r3.42 -r3.43
--- main.c	11 Sep 2003 05:12:50 -0000	3.42
+++ main.c	4 Feb 2004 15:56:07 -0000	3.43
@@ -561,6 +561,7 @@
 	ScreenPtr	pScreen;
 	DepthPtr	pDepth;
 	VisualPtr	pVisual;
+	VisualPtr	finalVisual;
 
 	pScreen = screenInfo.screens[i];
 	root.windowId = WindowTable[i]->drawable.id;
@@ -604,20 +605,28 @@
 	    for(k = 0; k < pDepth->numVids; k++)
 	    {
 		vid = pDepth->vids[k];
+		finalVisual=pScreen->visuals+pScreen->numVisuals;
 		for (pVisual = pScreen->visuals;
-		     pVisual->vid != vid;
+		     (pVisual<finalVisual) && (pVisual->vid != vid);
 		     pVisual++)
 		    ;
-		visual.visualID = vid;
-		visual.class = pVisual->class;
-		visual.bitsPerRGB = pVisual->bitsPerRGBValue;
-		visual.colormapEntries = pVisual->ColormapEntries;
-		visual.redMask = pVisual->redMask;
-		visual.greenMask = pVisual->greenMask;
-		visual.blueMask = pVisual->blueMask;
-		memmove(pBuf, (char *)&visual, sizeof(xVisualType));
-		pBuf += sizeof(xVisualType);
-		sizesofar += sizeof(xVisualType);
+		if(pVisual!=finalVisual)
+		{
+		    visual.visualID = vid;
+		    visual.class = pVisual->class;
+		    visual.bitsPerRGB = pVisual->bitsPerRGBValue;
+		    visual.colormapEntries = pVisual->ColormapEntries;
+		    visual.redMask = pVisual->redMask;
+		    visual.greenMask = pVisual->greenMask;
+		    visual.blueMask = pVisual->blueMask;
+		    memmove(pBuf, (char *)&visual, sizeof(xVisualType));
+		    pBuf += sizeof(xVisualType);
+		    sizesofar += sizeof(xVisualType);
+		}
+		else
+		{
+			FatalError("Visual specified by hardware layer, but not returned - this is a bug!");
+		}
 	    }
 	}
     }
@@ -664,6 +673,9 @@
     void	(**jNI) ();
 #endif /* DEBUG */
 
+    if(!pfnInit)
+	    FatalError("AddScreen called without pfnInit defined - this is a bug!");
+
     i = screenInfo.numScreens;
     if (i == MAXSCREENS)
 	return -1;
@@ -749,6 +761,7 @@
     WindowTable[i] = NullWindow;
     screenInfo.screens[i] = pScreen;
     screenInfo.numScreens++;
+
     if (!(*pfnInit)(i, pScreen, argc, argv))
     {
 	FreeScreen(pScreen);