[PATCH 4/4] Quit using clientErrorValue in dix/colormap.c.

Jamey Sharp jamey at minilop.net
Sat May 8 22:56:29 PDT 2010


And that's it! No more clientErrorValue kludge.

Signed-off-by: Jamey Sharp <jamey at minilop.net>
---
 dix/colormap.c             |   26 ++++++++++++--------------
 dix/dispatch.c             |   22 +++-------------------
 dix/window.c               |    2 +-
 hw/kdrive/src/kcmap.c      |    2 +-
 hw/vfb/InitOutput.c        |    2 +-
 hw/xfree86/vgahw/vgaCmap.c |    2 +-
 include/colormap.h         |    6 ++++--
 render/miindex.c           |    2 +-
 8 files changed, 24 insertions(+), 40 deletions(-)

diff --git a/dix/colormap.c b/dix/colormap.c
index bf97941..92fce3b 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -65,8 +65,6 @@ SOFTWARE.
 #include "privates.h"
 #include "xace.h"
 
-extern XID clientErrorValue;
-
 static Pixel FindBestPixel(
     EntryPtr /*pentFirst*/,
     int /*size*/,
@@ -1415,7 +1413,7 @@ BlueComp (EntryPtr pent, xrgb *prgb)
 /* Read the color value of a cell */
 
 int
-QueryColors (ColormapPtr pmap, int count, Pixel *ppixIn, xrgb *prgbList)
+QueryColors (ColormapPtr pmap, int count, Pixel *ppixIn, xrgb *prgbList, ClientPtr client)
 {
     Pixel	*ppix, pixel;
     xrgb	*prgb;
@@ -1438,14 +1436,14 @@ QueryColors (ColormapPtr pmap, int count, Pixel *ppixIn, xrgb *prgbList)
 	{
 	    pixel = *ppix;
 	    if (pixel & rgbbad) {
-		clientErrorValue = pixel;
+		client->errorValue = pixel;
 		errVal =  BadValue;
 		continue;
 	    }
 	    i  = (pixel & pVisual->redMask) >> pVisual->offsetRed;
 	    if (i >= numred)
 	    {
-		clientErrorValue = pixel;
+		client->errorValue = pixel;
 		errVal =  BadValue;
 		continue;
 	    }
@@ -1453,7 +1451,7 @@ QueryColors (ColormapPtr pmap, int count, Pixel *ppixIn, xrgb *prgbList)
 	    i  = (pixel & pVisual->greenMask) >> pVisual->offsetGreen;
 	    if (i >= numgreen)
 	    {
-		clientErrorValue = pixel;
+		client->errorValue = pixel;
 		errVal =  BadValue;
 		continue;
 	    }
@@ -1461,7 +1459,7 @@ QueryColors (ColormapPtr pmap, int count, Pixel *ppixIn, xrgb *prgbList)
 	    i  = (pixel & pVisual->blueMask) >> pVisual->offsetBlue;
 	    if (i >= numblue)
 	    {
-		clientErrorValue = pixel;
+		client->errorValue = pixel;
 		errVal =  BadValue;
 		continue;
 	    }
@@ -1475,7 +1473,7 @@ QueryColors (ColormapPtr pmap, int count, Pixel *ppixIn, xrgb *prgbList)
 	    pixel = *ppix;
 	    if (pixel >= pVisual->ColormapEntries)
 	    {
-		clientErrorValue = pixel;
+		client->errorValue = pixel;
 		errVal = BadValue;
 	    }
 	    else
@@ -2238,7 +2236,7 @@ FreeColors (ColormapPtr pmap, int client, int count, Pixel *pixels, Pixel mask)
     }
     if ((mask != rmask) && count)
     {
-	clientErrorValue = *pixels | mask;
+	clients[client]->errorValue = *pixels | mask;
 	result = BadValue;
     }
     /* XXX should worry about removing any RT_CMAPENTRY resource */
@@ -2320,7 +2318,7 @@ FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixe
 	    pixTest = ((*pptr | bits) & cmask) >> offset;
 	    if ((pixTest >= numents) || (*pptr & rgbbad))
 	    {
-		clientErrorValue = *pptr | bits;
+		clients[client]->errorValue = *pptr | bits;
 		errVal = BadValue;
 		continue;
 	    }
@@ -2401,7 +2399,7 @@ FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixe
 
 /* Redefine color values */
 int
-StoreColors (ColormapPtr pmap, int count, xColorItem *defs)
+StoreColors (ColormapPtr pmap, int count, xColorItem *defs, ClientPtr client)
 {
     Pixel 	pix;
     xColorItem *pdef;
@@ -2439,7 +2437,7 @@ StoreColors (ColormapPtr pmap, int count, xColorItem *defs)
 	    if (pdef->pixel & rgbbad)
 	    {
 		errVal = BadValue;
-		clientErrorValue = pdef->pixel;
+		client->errorValue = pdef->pixel;
 		continue;
 	    }
 	    pix = (pdef->pixel & pVisual->redMask) >> pVisual->offsetRed;
@@ -2511,7 +2509,7 @@ StoreColors (ColormapPtr pmap, int count, xColorItem *defs)
 		    defs[idef] = defs[n];
 		idef++;
 	    } else
-		clientErrorValue = pdef->pixel;
+		client->errorValue = pdef->pixel;
 	}
     }
     else
@@ -2522,7 +2520,7 @@ StoreColors (ColormapPtr pmap, int count, xColorItem *defs)
 	    ok = TRUE;
 	    if (pdef->pixel >= pVisual->ColormapEntries)
 	    {
-		clientErrorValue = pdef->pixel;
+		client->errorValue = pdef->pixel;
 	        errVal = BadValue;
 		ok = FALSE;
 	    }
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 92b8430..5b96f08 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -176,13 +176,6 @@ CallbackListPtr ClientStateCallback;
 volatile char dispatchException = 0;
 volatile char isItTimeToYield;
 
-/* Various of the DIX function interfaces were not designed to allow
- * the client->errorValue to be set on BadValue and other errors.
- * Rather than changing interfaces and breaking untold code we introduce
- * a new global that dispatch can use.
- */
-XID clientErrorValue;   /* XXX this is a kludge */
-
 #define SAME_SCREENS(a, b) (\
     (a.pScreen == b.pScreen))
 
@@ -2833,10 +2826,7 @@ ProcFreeColors(ClientPtr client)
         if (client->noClientException != Success)
             return(client->noClientException);
         else
-	{
-	    client->errorValue = clientErrorValue;
             return rc;
-	}
 
     }
     else
@@ -2864,14 +2854,11 @@ ProcStoreColors (ClientPtr client)
 	if (count % sizeof(xColorItem))
 	    return(BadLength);
 	count /= sizeof(xColorItem);
-	rc = StoreColors(pcmp, count, (xColorItem *)&stuff[1]);
+	rc = StoreColors(pcmp, count, (xColorItem *)&stuff[1], client);
         if (client->noClientException != Success)
             return(client->noClientException);
         else
-	{
-	    client->errorValue = clientErrorValue;
             return rc;
-	}
     }
     else
     {
@@ -2899,7 +2886,7 @@ ProcStoreNamedColor (ClientPtr client)
 	{
 	    def.flags = stuff->flags;
 	    def.pixel = stuff->pixel;
-	    rc = StoreColors(pcmp, 1, &def);
+	    rc = StoreColors(pcmp, 1, &def, client);
             if (client->noClientException != Success)
                 return(client->noClientException);
 	    else
@@ -2934,16 +2921,13 @@ ProcQueryColors(ClientPtr client)
 	prgbs = xcalloc(1, count * sizeof(xrgb));
 	if(!prgbs && count)
             return(BadAlloc);
-	if( (rc = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) )
+	if( (rc = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs, client)) )
 	{
    	    if (prgbs) xfree(prgbs);
 	    if (client->noClientException != Success)
                 return(client->noClientException);
 	    else
-	    {
-		client->errorValue = clientErrorValue;
 	        return rc;
-	    }
 	}
 	memset(&qcr, 0, sizeof(xQueryColorsReply));
 	qcr.type = X_Reply;
diff --git a/dix/window.c b/dix/window.c
index b5daf7f..cab7901 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -3743,7 +3743,7 @@ DrawLogo(WindowPtr pWin)
 
 	    querypixels[0] = fore[0].val;
 	    querypixels[1] = pWin->background.pixel;
-	    QueryColors(cmap, 2, querypixels, rgb);
+	    QueryColors(cmap, 2, querypixels, rgb, serverClient);
 	    if ((rgb[0].red == rgb[1].red) &&
 		(rgb[0].green == rgb[1].green) &&
 		(rgb[0].blue == rgb[1].blue)) {
diff --git a/hw/kdrive/src/kcmap.c b/hw/kdrive/src/kcmap.c
index 40697e0..9bfdd78 100644
--- a/hw/kdrive/src/kcmap.c
+++ b/hw/kdrive/src/kcmap.c
@@ -58,7 +58,7 @@ KdSetColormap (ScreenPtr pScreen)
     for (i = 0; i < (1 << pScreenPriv->screen->fb.depth); i++)
 	pixels[i] = i;
 
-    QueryColors (pCmap, (1 << pScreenPriv->screen->fb.depth), pixels, colors);
+    QueryColors (pCmap, (1 << pScreenPriv->screen->fb.depth), pixels, colors, serverClient);
 
     for (i = 0; i < (1 << pScreenPriv->screen->fb.depth); i++)
     {
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index 2985787..5963904 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -445,7 +445,7 @@ vfbInstallColormap(ColormapPtr pmap)
 
 	for (i = 0; i < entries; i++)  ppix[i] = i;
 	/* XXX truecolor */
-	QueryColors(pmap, entries, ppix, prgb);
+	QueryColors(pmap, entries, ppix, prgb, serverClient);
 
 	for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */
 	    defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */
diff --git a/hw/xfree86/vgahw/vgaCmap.c b/hw/xfree86/vgahw/vgaCmap.c
index 06eeb4c..e2c88b3 100644
--- a/hw/xfree86/vgahw/vgaCmap.c
+++ b/hw/xfree86/vgahw/vgaCmap.c
@@ -246,7 +246,7 @@ vgaInstallColormap(pmap)
 
   for ( i=0; i<entries; i++) ppix[i] = i;
 
-  QueryColors( pmap, entries, ppix, prgb);
+  QueryColors(pmap, entries, ppix, prgb, serverClient);
 
   for ( i=0; i<entries; i++) /* convert xrgbs to xColorItems */
     {
diff --git a/include/colormap.h b/include/colormap.h
index de48ce8..1b15748 100644
--- a/include/colormap.h
+++ b/include/colormap.h
@@ -135,7 +135,8 @@ extern _X_EXPORT int QueryColors(
     ColormapPtr /*pmap*/,
     int /*count*/,
     Pixel* /*ppixIn*/,
-    xrgb* /*prgbList*/);
+    xrgb* /*prgbList*/,
+    ClientPtr client);
 
 extern _X_EXPORT int FreeClientPixels(
     pointer /*pcr*/,
@@ -173,7 +174,8 @@ extern _X_EXPORT int FreeColors(
 extern _X_EXPORT int StoreColors(
     ColormapPtr /*pmap*/,
     int /*count*/,
-    xColorItem* /*defs*/);
+    xColorItem* /*defs*/,
+    ClientPtr client);
 
 extern _X_EXPORT int IsMapInstalled(
     Colormap /*map*/,
diff --git a/render/miindex.c b/render/miindex.c
index 4e0cf00..b6102e7 100644
--- a/render/miindex.c
+++ b/render/miindex.c
@@ -276,7 +276,7 @@ miInitIndexed (ScreenPtr	pScreen,
     /*
      * Build mapping from pixel value to ARGB
      */
-    QueryColors (pColormap, num, pixels, rgb);
+    QueryColors (pColormap, num, pixels, rgb, serverClient);
     for (i = 0; i < num; i++)
     {
 	p = pixels[i];
-- 
1.7.0



More information about the xorg-devel mailing list