[PATCH 6/6] Add typed resource-lookup errors for non-core resource types.

Jamey Sharp jamey at minilop.net
Sun Apr 25 03:35:38 PDT 2010


Signed-off-by: Jamey Sharp <jamey at minilop.net>
---

In several of these cases, I had a hard time determining whether a
resource type was initialized before or after the AddExtension call. I'd
appreciate review for whether I got that right in each case.

For example, on XRT_PICTURE I got lost and gave up: its error type is
set in whichever place finds both XRT_PICTURE and RenderErrBase set.

 Xext/panoramiX.c         |    4 ++
 Xext/panoramiXprocs.c    |  122 +++++++++++++++++++++++-----------------------
 Xext/saver.c             |    6 +-
 Xext/security.c          |    5 +-
 Xext/shape.c             |   12 ++--
 Xext/shm.c               |    5 +-
 Xext/sync.c              |   19 ++++---
 Xext/xvdisp.c            |   24 +++++-----
 Xext/xvdix.h             |    2 +-
 Xext/xvmain.c            |    1 +
 Xext/xvmc.c              |   15 +++---
 damageext/damageext.c    |    3 +-
 damageext/damageextint.h |    2 +-
 dbe/dbe.c                |    6 ++-
 dix/resource.c           |    6 ++
 include/resource.h       |    3 +
 randr/randrstr.h         |    6 +-
 randr/rrcrtc.c           |    3 +-
 randr/rrmode.c           |    1 +
 randr/rroutput.c         |    1 +
 record/record.c          |    5 +-
 render/picture.c         |    1 -
 render/picturestr.h      |    2 +-
 render/render.c          |   46 +++++++++++------
 xfixes/xfixes.c          |    1 +
 xfixes/xfixes.h          |    5 +--
 26 files changed, 169 insertions(+), 137 deletions(-)

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 96eb8f9..048c38e 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -518,6 +518,10 @@ void PanoramiXExtensionInit(int argc, char *argv[])
 	    panoramiXGeneration = serverGeneration;
 	    success = TRUE;
 	}
+	SetResourceTypeErrorValue(XRT_WINDOW, BadWindow);
+	SetResourceTypeErrorValue(XRT_PIXMAP, BadPixmap);
+	SetResourceTypeErrorValue(XRT_GC, BadGC);
+	SetResourceTypeErrorValue(XRT_COLORMAP, BadColor);
     }
 
     if (!success) {
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 8b0aeee..2719871 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -81,7 +81,7 @@ int PanoramiXCreateWindow(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&parent, stuff->parent,
 				     XRT_WINDOW, client, DixWriteAccess);
     if (result != Success)
-        return (result == BadValue) ? BadWindow : result;
+        return result;
 
     if(stuff->class == CopyFromParent)
 	stuff->class = parent->u.win.class;
@@ -96,7 +96,7 @@ int PanoramiXCreateWindow(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&backPix, tmp,
 					     XRT_PIXMAP, client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadPixmap : result;
+		return result;
 	}
     }
     if ((Mask)stuff->mask & CWBorderPixmap) {
@@ -106,7 +106,7 @@ int PanoramiXCreateWindow(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&bordPix, tmp,
 					     XRT_PIXMAP, client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadPixmap : result;
+		return result;
 	}
     }
     if ((Mask)stuff->mask & CWColormap) {
@@ -116,7 +116,7 @@ int PanoramiXCreateWindow(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&cmap, tmp,
 					     XRT_COLORMAP, client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadColor : result;
+		return result;
 	}
     }
 
@@ -186,7 +186,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->window,
 				     XRT_WINDOW, client, DixWriteAccess);
     if (result != Success)
-        return (result == BadValue) ? BadWindow : result;
+        return result;
 
     if((win->u.win.class == InputOnly) && 
        (stuff->valueMask & (~INPUTONLY_LEGAL_MASK)))
@@ -199,7 +199,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&backPix, tmp,
 					     XRT_PIXMAP, client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadPixmap : result;
+		return result;
 	}
     }
     if ((Mask)stuff->valueMask & CWBorderPixmap) {
@@ -209,7 +209,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&bordPix, tmp,
 					     XRT_PIXMAP, client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadPixmap : result;
+		return result;
 	}
     }
     if ((Mask)stuff->valueMask & CWColormap) {
@@ -219,7 +219,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&cmap, tmp,
 					     XRT_COLORMAP, client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadColor : result;
+		return result;
 	}
     }
 
@@ -249,7 +249,7 @@ int PanoramiXDestroyWindow(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW,
 				     client, DixDestroyAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->id = win->info[j].id;
@@ -275,7 +275,7 @@ int PanoramiXDestroySubwindows(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW,
 				     client, DixDestroyAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->id = win->info[j].id;
@@ -301,7 +301,7 @@ int PanoramiXChangeSaveSet(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->window,
 				     XRT_WINDOW, client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->window = win->info[j].id;
@@ -326,12 +326,12 @@ int PanoramiXReparentWindow(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->window,
 				     XRT_WINDOW, client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     result = dixLookupResourceByType((pointer *)&parent, stuff->parent,
 				     XRT_WINDOW, client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     x = stuff->x;
     y = stuff->y;
@@ -363,7 +363,7 @@ int PanoramiXMapWindow(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->id,
 				     XRT_WINDOW, client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     FOR_NSCREENS_FORWARD(j) {
 	stuff->id = win->info[j].id;
@@ -386,7 +386,7 @@ int PanoramiXMapSubwindows(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->id,
 				     XRT_WINDOW, client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     FOR_NSCREENS_FORWARD(j) {
 	stuff->id = win->info[j].id;
@@ -409,7 +409,7 @@ int PanoramiXUnmapWindow(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->id,
 				     XRT_WINDOW, client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     FOR_NSCREENS_FORWARD(j) {
 	stuff->id = win->info[j].id;
@@ -432,7 +432,7 @@ int PanoramiXUnmapSubwindows(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->id,
 				     XRT_WINDOW, client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     FOR_NSCREENS_FORWARD(j) {
 	stuff->id = win->info[j].id;
@@ -469,7 +469,7 @@ int PanoramiXConfigureWindow(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->window,
 				     XRT_WINDOW, client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     if ((Mask)stuff->mask & CWSibling) {
 	XID tmp;
@@ -478,7 +478,7 @@ int PanoramiXConfigureWindow(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&sib, tmp, XRT_WINDOW,
 					     client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadWindow : result;
+		return result;
 	}
     }
 
@@ -524,7 +524,7 @@ int PanoramiXCirculateWindow(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->window,
 				     XRT_WINDOW, client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     FOR_NSCREENS_FORWARD(j) {
 	stuff->window = win->info[j].id;
@@ -704,7 +704,7 @@ int PanoramiXFreePixmap(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&pix, stuff->id, XRT_PIXMAP,
 				     client, DixDestroyAccess);
     if (result != Success)
-	return (result == BadValue) ? BadPixmap : result;
+	return result;
 
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->id = pix->info[j].id;
@@ -749,7 +749,7 @@ int PanoramiXCreateGC(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP,
 					     client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadPixmap : result;
+		return result;
 	}
     }
     if ((Mask)stuff->mask & GCStipple) {
@@ -758,7 +758,7 @@ int PanoramiXCreateGC(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP,
 					     client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadPixmap : result;
+		return result;
 	}
     }
     if ((Mask)stuff->mask & GCClipMask) {
@@ -767,7 +767,7 @@ int PanoramiXCreateGC(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP,
 					     client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadPixmap : result;
+		return result;
 	}
     }
 
@@ -820,7 +820,7 @@ int PanoramiXChangeGC(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     if ((Mask)stuff->mask & GCTile) {
 	tile_offset = Ones((Mask)stuff->mask & (GCTile - 1));
@@ -828,7 +828,7 @@ int PanoramiXChangeGC(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP,
 					     client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadPixmap : result;
+		return result;
 	}
     }
     if ((Mask)stuff->mask & GCStipple) {
@@ -837,7 +837,7 @@ int PanoramiXChangeGC(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP,
 					     client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadPixmap : result;
+		return result;
 	}
     }
     if ((Mask)stuff->mask & GCClipMask) {
@@ -846,7 +846,7 @@ int PanoramiXChangeGC(ClientPtr client)
 	    result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP,
 					     client, DixReadAccess);
 	    if (result != Success)
-		return (result == BadValue) ? BadPixmap : result;
+		return result;
 	}
     }
 
@@ -878,12 +878,12 @@ int PanoramiXCopyGC(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&srcGC, stuff->srcGC, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     result = dixLookupResourceByType((pointer *)&dstGC, stuff->dstGC, XRT_GC,
 				     client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     FOR_NSCREENS(j) {
 	stuff->srcGC = srcGC->info[j].id;
@@ -907,7 +907,7 @@ int PanoramiXSetDashes(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->gc = gc->info[j].id;
@@ -930,7 +930,7 @@ int PanoramiXSetClipRectangles(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->gc = gc->info[j].id;
@@ -953,7 +953,7 @@ int PanoramiXFreeGC(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->id, XRT_GC,
 				     client, DixDestroyAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->id = gc->info[j].id;
@@ -980,7 +980,7 @@ int PanoramiXClearToBackground(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->window,
 				     XRT_WINDOW, client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     x = stuff->x;
     y = stuff->y;
@@ -1040,7 +1040,7 @@ int PanoramiXCopyArea(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     if((dst->type == XRT_WINDOW) && dst->u.win.root)
 	dstIsRoot = TRUE;
@@ -1199,7 +1199,7 @@ int PanoramiXCopyPlane(ClientPtr client)
     rc = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				 client, DixReadAccess);
     if (rc != Success)
-	return (rc == BadValue) ? BadGC : rc;
+	return rc;
 
     if((dst->type == XRT_WINDOW) && dst->u.win.root)
 	dstIsRoot = TRUE;
@@ -1296,7 +1296,7 @@ int PanoramiXPolyPoint(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
     npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
@@ -1356,7 +1356,7 @@ int PanoramiXPolyLine(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
     npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
@@ -1416,7 +1416,7 @@ int PanoramiXPolySegment(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -1479,7 +1479,7 @@ int PanoramiXPolyRectangle(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -1541,7 +1541,7 @@ int PanoramiXPolyArc(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -1601,7 +1601,7 @@ int PanoramiXFillPoly(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -1662,7 +1662,7 @@ int PanoramiXPolyFillRectangle(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -1723,7 +1723,7 @@ int PanoramiXPolyFillArc(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -1783,7 +1783,7 @@ int PanoramiXPutImage(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -1984,7 +1984,7 @@ PanoramiXPolyText8(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -2025,7 +2025,7 @@ PanoramiXPolyText16(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -2066,7 +2066,7 @@ int PanoramiXImageText8(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -2107,7 +2107,7 @@ int PanoramiXImageText16(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadGC : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -2139,7 +2139,7 @@ int PanoramiXCreateColormap(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&win, stuff->window,
 				     XRT_WINDOW, client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     if(!(newCmap = xalloc(sizeof(PanoramiXRes))))
         return BadAlloc;
@@ -2180,7 +2180,7 @@ int PanoramiXFreeColormap(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP,
 				     client, DixDestroyAccess);
     if (result != Success)
-        return (result == BadValue) ? BadColor : result;
+        return result;
 
     FOR_NSCREENS_BACKWARD(j) {
         stuff->id = cmap->info[j].id;
@@ -2210,7 +2210,7 @@ PanoramiXCopyColormapAndFree(ClientPtr client)
 				     XRT_COLORMAP, client,
 				     DixReadAccess | DixWriteAccess);
     if (result != Success)
-        return (result == BadValue) ? BadColor : result;
+        return result;
 
     if(!(newCmap = xalloc(sizeof(PanoramiXRes))))
         return BadAlloc;
@@ -2249,7 +2249,7 @@ int PanoramiXInstallColormap(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP,
 				     client, DixReadAccess);
     if (result != Success)
-        return (result == BadValue) ? BadColor : result;
+        return result;
 
     FOR_NSCREENS_BACKWARD(j){
 	stuff->id = cmap->info[j].id;
@@ -2273,7 +2273,7 @@ int PanoramiXUninstallColormap(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP,
 				     client, DixReadAccess);
     if (result != Success)
-        return (result == BadValue) ? BadColor : result;
+        return result;
 
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->id = cmap->info[j].id;
@@ -2297,7 +2297,7 @@ int PanoramiXAllocColor(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
 				     XRT_COLORMAP, client, DixWriteAccess);
     if (result != Success)
-        return (result == BadValue) ? BadColor : result;
+        return result;
 
     FOR_NSCREENS_BACKWARD(j){
 	stuff->cmap = cmap->info[j].id;
@@ -2321,7 +2321,7 @@ int PanoramiXAllocNamedColor(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
 				     XRT_COLORMAP, client, DixWriteAccess);
     if (result != Success)
-        return (result == BadValue) ? BadColor : result;
+        return result;
 
     FOR_NSCREENS_BACKWARD(j){
         stuff->cmap = cmap->info[j].id;
@@ -2345,7 +2345,7 @@ int PanoramiXAllocColorCells(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
 				     XRT_COLORMAP, client, DixWriteAccess);
     if (result != Success)
-        return (result == BadValue) ? BadColor : result;
+        return result;
 	
     FOR_NSCREENS_BACKWARD(j){
 	stuff->cmap = cmap->info[j].id;
@@ -2369,7 +2369,7 @@ int PanoramiXAllocColorPlanes(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
 				     XRT_COLORMAP, client, DixWriteAccess);
     if (result != Success)
-        return (result == BadValue) ? BadColor : result;
+        return result;
 	
     FOR_NSCREENS_BACKWARD(j){
 	stuff->cmap = cmap->info[j].id;
@@ -2394,7 +2394,7 @@ int PanoramiXFreeColors(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
 				     XRT_COLORMAP, client, DixWriteAccess);
     if (result != Success)
-        return (result == BadValue) ? BadColor : result;
+        return result;
 
     FOR_NSCREENS_BACKWARD(j) {
         stuff->cmap = cmap->info[j].id;
@@ -2417,7 +2417,7 @@ int PanoramiXStoreColors(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
 				     XRT_COLORMAP, client, DixWriteAccess);
     if (result != Success)
-        return (result == BadValue) ? BadColor : result;
+        return result;
 
     FOR_NSCREENS_BACKWARD(j){
 	stuff->cmap = cmap->info[j].id;
@@ -2441,7 +2441,7 @@ int PanoramiXStoreNamedColor(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap,
 				     XRT_COLORMAP, client, DixWriteAccess);
     if (result != Success)
-        return (result == BadValue) ? BadColor : result;
+        return result;
 
     FOR_NSCREENS_BACKWARD(j){
 	stuff->cmap = cmap->info[j].id;
diff --git a/Xext/saver.c b/Xext/saver.c
index 0640131..8f4c815 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -1277,7 +1277,7 @@ ProcScreenSaverSetAttributes (ClientPtr client)
 					       XRT_PIXMAP, client,
 					       DixReadAccess);
 	      if (status != Success)
-		  return (status == BadValue) ? BadPixmap : status;
+		  return status;
           }
        }
 
@@ -1289,7 +1289,7 @@ ProcScreenSaverSetAttributes (ClientPtr client)
 					       XRT_PIXMAP, client,
 					       DixReadAccess);
 	      if (status != Success)
-		  return (status == BadValue) ? BadPixmap : status;
+		  return status;
           }
        }
 
@@ -1301,7 +1301,7 @@ ProcScreenSaverSetAttributes (ClientPtr client)
 						XRT_COLORMAP, client,
 						DixReadAccess);
 	       if (status != Success)
-		   return (status == BadValue) ? BadColor : status;
+		   return status;
            }
        }
 
diff --git a/Xext/security.c b/Xext/security.c
index af8d205..c85e9cf 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -632,8 +632,7 @@ ProcSecurityRevokeAuthorization(
 				 SecurityAuthorizationResType, client,
 				 DixDestroyAccess);
     if (rc != Success)
-	return (rc == BadValue) ?
-	    SecurityErrorBase + XSecurityBadAuthorization : rc;
+	return rc;
 
     FreeResource(stuff->authId, RT_NONE);
     return Success;
@@ -1149,6 +1148,8 @@ SecurityExtensionInit(INITARGS)
     EventSwapVector[SecurityEventBase + XSecurityAuthorizationRevoked] =
 	(EventSwapPtr)SwapSecurityAuthorizationRevokedEvent;
 
+    SetResourceTypeErrorValue(SecurityAuthorizationResType, SecurityErrorBase + XSecurityBadAuthorization);
+
     /* Label objects that were created before we could register ourself */
     SecurityLabelInitial();
 }
diff --git a/Xext/shape.c b/Xext/shape.c
index 7a1753f..1858830 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -360,7 +360,7 @@ ProcPanoramiXShapeRectangles(
     result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
 				     client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     FOR_NSCREENS(j) {
 	stuff->dest = win->info[j].id;
@@ -459,13 +459,13 @@ ProcPanoramiXShapeMask(
     result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
 				     client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     if(stuff->src != None) {
 	result = dixLookupResourceByType((pointer *)&pmap, stuff->src,
 					 XRT_PIXMAP, client, DixReadAccess);
 	if (result != Success)
-	    return (result == BadValue) ? BadPixmap : result;
+	    return result;
     } else
 	pmap = NULL;
 
@@ -589,12 +589,12 @@ ProcPanoramiXShapeCombine(
     result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
 				     client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     result = dixLookupResourceByType((pointer *)&win2, stuff->src, XRT_WINDOW,
 				     client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     FOR_NSCREENS(j) {
 	stuff->dest = win->info[j].id;
@@ -663,7 +663,7 @@ ProcPanoramiXShapeOffset(
     result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW,
 				     client, DixWriteAccess);
     if (result != Success)
-	return (result == BadValue) ? BadWindow : result;
+	return result;
 
     FOR_NSCREENS(j) {
 	stuff->dest = win->info[j].id;
diff --git a/Xext/shm.c b/Xext/shm.c
index ab58c27..575094b 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -156,7 +156,7 @@ static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL};
     rc = dixLookupResourceByType((pointer *)&(shmdesc), shmseg, ShmSegType, \
                                  client, DixReadAccess); \
     if (rc != Success) \
-	return (rc == BadValue) ? BadShmSegCode : rc; \
+	return rc; \
 }
 
 #define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \
@@ -286,6 +286,7 @@ ShmExtensionInit(INITARGS)
 	ShmReqCode = (unsigned char)extEntry->base;
 	ShmCompletionCode = extEntry->eventBase;
 	BadShmSegCode = extEntry->errorBase;
+	SetResourceTypeErrorValue(ShmSegType, BadShmSegCode);
 	EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent;
     }
 }
@@ -584,7 +585,7 @@ ProcPanoramiXShmPutImage(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
 				     XRT_GC, client, DixReadAccess);
     if (result != Success)
-        return (result == BadValue) ? BadGC : result;
+        return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
diff --git a/Xext/sync.c b/Xext/sync.c
index 990cb67..2037a41 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -264,7 +264,7 @@ SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XSyncCounter counter,
 				counter, RTCounter, client, DixReadAccess)))
 	{
 	    client->errorValue = counter;
-	    return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
+	    return rc;
 	}
 	if (pCounter != pTrigger->pCounter)
 	{ /* new counter for trigger */
@@ -1339,7 +1339,7 @@ ProcSyncSetCounter(ClientPtr client)
     rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
 				 client, DixWriteAccess);
     if (rc != Success)
-	return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
+	return rc;
 
     if (IsSystemCounter(pCounter))
     {
@@ -1369,7 +1369,7 @@ ProcSyncChangeCounter(ClientPtr client)
     rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
 				 client, DixWriteAccess);
     if (rc != Success)
-	return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
+	return rc;
 
     if (IsSystemCounter(pCounter))
     {
@@ -1404,7 +1404,7 @@ ProcSyncDestroyCounter(ClientPtr client)
     rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, RTCounter,
 				 client, DixDestroyAccess);
     if (rc != Success)
-	return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
+	return rc;
 
     if (IsSystemCounter(pCounter))
     {
@@ -1547,7 +1547,7 @@ ProcSyncQueryCounter(ClientPtr client)
     rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter,
 				 RTCounter, client, DixReadAccess);
     if (rc != Success)
-	return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
+	return rc;
 
     rep.type = X_Reply;
     rep.length = 0;
@@ -1671,7 +1671,7 @@ ProcSyncChangeAlarm(ClientPtr client)
     status = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
 				     client, DixWriteAccess);
     if (status != Success)
-	return (status == BadValue) ? SyncErrorBase + XSyncBadAlarm : status;
+	return status;
 
     vmask = stuff->valueMask;
     len = client->req_len - bytes_to_int32(sizeof(xSyncChangeAlarmReq));
@@ -1710,7 +1710,7 @@ ProcSyncQueryAlarm(ClientPtr client)
     rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
 				 client, DixReadAccess);
     if (rc != Success)
-	return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc;
+	return rc;
 
     rep.type = X_Reply;
     rep.length = bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply));
@@ -1767,7 +1767,7 @@ ProcSyncDestroyAlarm(ClientPtr client)
     rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
 				 client, DixDestroyAccess);
     if (rc != Success)
-	return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc;
+	return rc;
 
     FreeResource(stuff->alarm, RT_NONE);
     return client->noClientException;
@@ -2138,6 +2138,9 @@ SyncExtensionInit(void)
     EventSwapVector[SyncEventBase + XSyncCounterNotify] = (EventSwapPtr) SCounterNotifyEvent;
     EventSwapVector[SyncEventBase + XSyncAlarmNotify] = (EventSwapPtr) SAlarmNotifyEvent;
 
+    SetResourceTypeErrorValue(RTCounter, SyncErrorBase + XSyncBadCounter);
+    SetResourceTypeErrorValue(RTAlarm, SyncErrorBase + XSyncBadAlarm);
+
     /*
      * Although SERVERTIME is implemented by the OS layer, we initialise it
      * here because doing it in OsInit() is too early. The resource database
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index b6fc34f..8f20c39 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -1025,7 +1025,6 @@ typedef struct _ShmDesc {
 } ShmDescRec, *ShmDescPtr;
 
 extern RESTYPE ShmSegType;
-extern int BadShmSegCode;
 extern int ShmCompletionCode;
 
 static int 
@@ -1077,7 +1076,7 @@ ProcXvShmPutImage(ClientPtr client)
   status = dixLookupResourceByType((pointer *)&shmdesc, stuff->shmseg,
 				   ShmSegType, serverClient, DixReadAccess);
   if (status != Success)
-      return (status == BadValue) ? BadShmSegCode : status;
+      return status;
  
   width = stuff->width;
   height = stuff->height;
@@ -1616,7 +1615,7 @@ XineramaXvStopVideo(ClientPtr client)
    result = dixLookupResourceByType((pointer *)&port, stuff->port,
 				    XvXRTPort, client, DixReadAccess);
    if (result != Success)
-       return (result == BadValue) ? _XvBadPort : result;
+       return result;
 
    FOR_NSCREENS_BACKWARD(i) {
 	if(port->info[i].id) {
@@ -1641,7 +1640,7 @@ XineramaXvSetPortAttribute(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&port, stuff->port,
 				     XvXRTPort, client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? _XvBadPort : result;
+	return result;
 
     FOR_NSCREENS_BACKWARD(i) {
 	if(port->info[i].id) {
@@ -1672,12 +1671,12 @@ XineramaXvShmPutImage(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
 				     XRT_GC, client, DixReadAccess);
     if (result != Success)
-        return (result == BadValue) ? BadGC : result;
+        return result;
 
     result = dixLookupResourceByType((pointer *)&port, stuff->port,
 				     XvXRTPort, client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? _XvBadPort : result;
+	return result;
  
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -1724,12 +1723,12 @@ XineramaXvPutImage(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
 				     XRT_GC, client, DixReadAccess);
     if (result != Success)
-        return (result == BadValue) ? BadGC : result;
+        return result;
 
     result = dixLookupResourceByType((pointer *)&port, stuff->port,
 				     XvXRTPort, client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? _XvBadPort : result;
+	return result;
  
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -1772,12 +1771,12 @@ XineramaXvPutVideo(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
 				     XRT_GC, client, DixReadAccess);
     if (result != Success)
-        return (result == BadValue) ? BadGC : result;
+        return result;
 
     result = dixLookupResourceByType((pointer *)&port, stuff->port,
 				     XvXRTPort, client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? _XvBadPort : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -1820,12 +1819,12 @@ XineramaXvPutStill(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&gc, stuff->gc,
 				     XRT_GC, client, DixReadAccess);
     if (result != Success)
-        return (result == BadValue) ? BadGC : result;
+        return result;
 
     result = dixLookupResourceByType((pointer *)&port, stuff->port,
 				     XvXRTPort, client, DixReadAccess);
     if (result != Success)
-	return (result == BadValue) ? _XvBadPort : result;
+	return result;
 
     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
 
@@ -1866,6 +1865,7 @@ void XineramifyXv(void)
    XvXRTPort = CreateNewResourceType(XineramaDeleteResource, "XvXRTPort");
 
    if (!xvsp0 || !XvXRTPort) return;
+   SetResourceTypeErrorValue(XvXRTPort, _XvBadPort);
 
    for(i = 0; i < xvsp0->nAdaptors; i++) {
       refAdapt = xvsp0->pAdaptors + i;
diff --git a/Xext/xvdix.h b/Xext/xvdix.h
index 44f8f6b..a210615 100644
--- a/Xext/xvdix.h
+++ b/Xext/xvdix.h
@@ -206,7 +206,7 @@ typedef struct _XvPortRec {
 	int rc = dixLookupResourceByType((pointer *)&(pPort), portID,\
 	                                 XvRTPort, client, mode);\
 	if (rc != Success)\
-	    return (rc == BadValue) ? _XvBadPort : rc;\
+	    return rc;\
     }
 
 typedef struct {
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index 05a6890..c3981ae 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -194,6 +194,7 @@ XvExtensionInit(void)
       EventSwapVector[XvEventBase+XvPortNotify] = 
 	(EventSwapPtr)WriteSwappedPortNotifyEvent;
 
+      SetResourceTypeErrorValue(XvRTPort, _XvBadPort);
       (void)MakeAtom(XvName, strlen(XvName), xTrue);
 
     }
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index c85f85e..36051e7 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -40,7 +40,6 @@ unsigned long XvMCGeneration = 0;
 
 int XvMCReqCode;
 int XvMCEventBase;
-int XvMCErrorBase;
 
 unsigned long XvMCRTContext;
 unsigned long XvMCRTSurface;
@@ -276,7 +275,7 @@ ProcXvMCDestroyContext(ClientPtr client)
     rc = dixLookupResourceByType(&val, stuff->context_id, XvMCRTContext,
 				 client, DixDestroyAccess);
     if (rc != Success)
-	return (rc == BadValue) ? XvMCBadContext + XvMCErrorBase : rc;
+	return rc;
 
     FreeResource(stuff->context_id, RT_NONE); 
 
@@ -299,7 +298,7 @@ ProcXvMCCreateSurface(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&pContext, stuff->context_id,
 				     XvMCRTContext, client, DixUseAccess);
     if (result != Success)
-        return (result == BadValue) ? XvMCBadContext + XvMCErrorBase : result;
+        return result;
 
     pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
 
@@ -346,7 +345,7 @@ ProcXvMCDestroySurface(ClientPtr client)
     rc = dixLookupResourceByType(&val, stuff->surface_id, XvMCRTSurface,
 				 client, DixDestroyAccess);
     if (rc != Success)
-        return (rc == BadValue) ? XvMCBadSurface + XvMCErrorBase : rc;
+        return rc;
 
     FreeResource(stuff->surface_id, RT_NONE);
 
@@ -371,7 +370,7 @@ ProcXvMCCreateSubpicture(ClientPtr client)
     result = dixLookupResourceByType((pointer *)&pContext, stuff->context_id,
 				     XvMCRTContext, client, DixUseAccess);
     if (result != Success)
-        return (result == BadValue) ? XvMCBadContext + XvMCErrorBase : result;
+        return result;
 
     pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
 
@@ -463,7 +462,7 @@ ProcXvMCDestroySubpicture(ClientPtr client)
     rc = dixLookupResourceByType(&val, stuff->subpicture_id, XvMCRTSubpicture,
 				 client, DixDestroyAccess);
     if (rc != Success)
-        return (rc == BadValue) ? XvMCBadSubpicture + XvMCErrorBase : rc;
+        return rc;
 
     FreeResource(stuff->subpicture_id, RT_NONE);
 
@@ -694,7 +693,9 @@ XvMCExtensionInit(void)
   
    XvMCReqCode = extEntry->base;
    XvMCEventBase = extEntry->eventBase;
-   XvMCErrorBase = extEntry->errorBase;
+   SetResourceTypeErrorValue(XvMCRTContext, extEntry->errorBase + XvMCBadContext);
+   SetResourceTypeErrorValue(XvMCRTSurface, extEntry->errorBase + XvMCBadSurface);
+   SetResourceTypeErrorValue(XvMCRTSubpicture, extEntry->errorBase + XvMCBadSubpicture);
 }
 
 static Bool
diff --git a/damageext/damageext.c b/damageext/damageext.c
index 462796e..ba8fc9e 100644
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -29,7 +29,6 @@
 
 static unsigned char	DamageReqCode;
 static int		DamageEventBase;
-static int		DamageErrorBase;
 static RESTYPE		DamageExtType;
 static RESTYPE		DamageExtWinType;
 
@@ -517,8 +516,8 @@ DamageExtensionInit(void)
     {
 	DamageReqCode = (unsigned char)extEntry->base;
 	DamageEventBase = extEntry->eventBase;
-	DamageErrorBase = extEntry->errorBase;
 	EventSwapVector[DamageEventBase + XDamageNotify] =
 			(EventSwapPtr) SDamageNotifyEvent;
+	SetResourceTypeErrorValue(DamageExtType, extEntry->errorBase + BadDamage);
     }
 }
diff --git a/damageext/damageextint.h b/damageext/damageextint.h
index 45c5ff9..3dbf7a8 100644
--- a/damageext/damageextint.h
+++ b/damageext/damageextint.h
@@ -61,7 +61,7 @@ typedef struct _DamageExt {
     int rc = dixLookupResourceByType((pointer *)&(pDamageExt), rid, \
                                      DamageExtType, client, mode); \
     if (rc != Success) \
-        return (rc == BadValue) ? DamageErrorBase + BadDamage : rc; \
+        return rc; \
 }
 
 void
diff --git a/dbe/dbe.c b/dbe/dbe.c
index 825d2e0..b48721f 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -422,12 +422,12 @@ ProcDbeDeallocateBackBufferName(ClientPtr client)
 				 dbeWindowPrivResType, client,
 				 DixDestroyAccess);
     if (rc != Success)
-	return (rc == BadValue) ? dbeErrorBase + DbeBadBuffer : rc;
+	return rc;
 
     rc = dixLookupResourceByType(&val, stuff->buffer, dbeDrawableResType,
 				 client, DixDestroyAccess);
     if (rc != Success)
-	return (rc == BadValue) ? dbeErrorBase + DbeBadBuffer : rc;
+	return rc;
 
     /* Make sure that the id is valid for the window.
      * This is paranoid code since we already looked up the ID by type
@@ -1680,6 +1680,8 @@ DbeExtensionInit(void)
                             DbeResetProc, StandardMinorOpcode);
 
     dbeErrorBase = extEntry->errorBase;
+    SetResourceTypeErrorValue(dbeWindowPrivResType, dbeErrorBase + DbeBadBuffer);
+    SetResourceTypeErrorValue(dbeDrawableResType, dbeErrorBase + DbeBadBuffer);
 
 } /* DbeExtensionInit() */
 
diff --git a/dix/resource.c b/dix/resource.c
index 6938569..588a8d8 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -268,6 +268,12 @@ CreateNewResourceType(DeleteType deleteFunc, char *name)
     return next;
 }
 
+void
+SetResourceTypeErrorValue(RESTYPE type, int errorValue)
+{
+    resourceTypes[type & TypeMask].errorValue = errorValue;
+}
+
 RESTYPE
 CreateNewResourceClass(void)
 {
diff --git a/include/resource.h b/include/resource.h
index 7948af5..2973d5a 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -157,6 +157,9 @@ typedef Bool (*FindComplexResType)(
 extern _X_EXPORT RESTYPE CreateNewResourceType(
     DeleteType /*deleteFunc*/, char * /*name*/);
 
+extern _X_EXPORT void SetResourceTypeErrorValue(
+    RESTYPE /*type*/, int /*errorValue*/);
+
 extern _X_EXPORT RESTYPE CreateNewResourceClass(void);
 
 extern _X_EXPORT Bool InitClientResources(
diff --git a/randr/randrstr.h b/randr/randrstr.h
index b163a73..a18c834 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -344,7 +344,7 @@ extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType;
 	                                 RROutputType, client, a);\
 	if (rc != Success) {\
 	    client->errorValue = id;\
-	    return (rc == BadValue) ? RRErrorBase + BadRROutput : rc;\
+	    return rc;\
 	}\
     }
 
@@ -354,7 +354,7 @@ extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType;
 	                                 RRCrtcType, client, a);\
 	if (rc != Success) {\
 	    client->errorValue = id;\
-	    return (rc == BadValue) ? RRErrorBase + BadRRCrtc : rc;\
+	    return rc;\
 	}\
     }
 
@@ -364,7 +364,7 @@ extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType;
 	                                 RRModeType, client, a);\
 	if (rc != Success) {\
 	    client->errorValue = id;\
-	    return (rc == BadValue) ? RRErrorBase + BadRRMode : rc;\
+	    return rc;\
 	}\
     }
 
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index a9eb2d2..bf104a4 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -635,6 +635,7 @@ RRCrtcInit (void)
     RRCrtcType = CreateNewResourceType (RRCrtcDestroyResource, "CRTC");
     if (!RRCrtcType)
 	return FALSE;
+    SetResourceTypeErrorValue(RRCrtcType, RRErrorBase + BadRRCrtc);
     return TRUE;
 }
 
@@ -807,7 +808,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
 	{
 	    if (outputs)
 		xfree (outputs);
-	    return (rc == BadValue) ? RRErrorBase + BadRROutput : rc;
+	    return rc;
 	}
 	/* validate crtc for this output */
 	for (j = 0; j < outputs[i]->numCrtcs; j++)
diff --git a/randr/rrmode.c b/randr/rrmode.c
index 1396193..2db81a3 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -268,6 +268,7 @@ RRModeInit (void)
     RRModeType = CreateNewResourceType (RRModeDestroyResource, "MODE");
     if (!RRModeType)
 	return FALSE;
+    SetResourceTypeErrorValue(RRModeType, RRErrorBase + BadRRMode);
     return TRUE;
 }
 
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 3a1b8bb..bd14f93 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -424,6 +424,7 @@ RROutputInit (void)
     RROutputType = CreateNewResourceType (RROutputDestroyResource, "OUTPUT");
     if (!RROutputType)
 	return FALSE;
+    SetResourceTypeErrorValue(RROutputType, RRErrorBase + BadRROutput);
     return TRUE;
 }
 
diff --git a/record/record.c b/record/record.c
index 1a10c9e..fe605c4 100644
--- a/record/record.c
+++ b/record/record.c
@@ -58,7 +58,6 @@ and Jim Haggerty of Metheus.
 #include "protocol-versions.h"
 
 static RESTYPE RTContext;   /* internal resource type for Record contexts */
-static int RecordErrorBase; /* first Record error number */
 
 /* How many bytes of protocol data to buffer in a context. Don't set to less
  * than 32.
@@ -133,7 +132,7 @@ static int numEnabledRCAPs;
     int rc = dixLookupResourceByType((pointer *)&(_pContext), _contextid, \
                                      RTContext, _client, DixUseAccess); \
     if (rc != Success) \
-	return (rc == BadValue) ? RecordErrorBase + XRecordBadContext : rc; \
+	return rc; \
 }
 
 static int RecordDeleteContext(
@@ -2911,7 +2910,7 @@ RecordExtensionInit(void)
 	DeleteCallback(&ClientStateCallback, RecordAClientStateChange, NULL);
 	return;
     }
-    RecordErrorBase = extentry->errorBase;
+    SetResourceTypeErrorValue(RTContext, extentry->errorBase + XRecordBadContext);
 
 } /* RecordExtensionInit */
 
diff --git a/render/picture.c b/render/picture.c
index 8ddec22..cd2fcba 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -1115,7 +1115,6 @@ ChangePicture (PicturePtr	pPicture,
 			if (error != Success)
 			{
 			    client->errorValue = pid;
-			    error = (error == BadValue) ? RenderErrBase + BadPicture : error;
 			    break;
 			}
 			if (pAlpha->pDrawable == NULL ||
diff --git a/render/picturestr.h b/render/picturestr.h
index 5a796f4..a401108 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -412,7 +412,7 @@ extern _X_EXPORT RESTYPE	GlyphSetType;
     int rc = dixLookupResourceByType((pointer)&(pPicture), pid,\
 	                             PictureType, client, mode);\
     if (rc != Success)\
-	return (rc == BadValue) ? RenderErrBase + BadPicture : rc;\
+	return rc;\
 }
 
 #define VERIFY_ALPHA(pPicture, pid, client, mode) {\
diff --git a/render/render.c b/render/render.c
index 726d2ec..b063cc9 100644
--- a/render/render.c
+++ b/render/render.c
@@ -233,6 +233,10 @@ RenderClientCallback (CallbackListPtr	*list,
     pRenderClient->minor_version = 0;
 }
 
+#ifdef PANORAMIX
+unsigned long	XRT_PICTURE;
+#endif
+
 void
 RenderExtensionInit (void)
 {
@@ -253,6 +257,13 @@ RenderExtensionInit (void)
     if (!extEntry)
 	return;
     RenderErrBase = extEntry->errorBase;
+#ifdef PANORAMIX
+    if (XRT_PICTURE)
+	SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture);
+#endif
+    SetResourceTypeErrorValue(PictureType, RenderErrBase + BadPicture);
+    SetResourceTypeErrorValue(PictFormatType, RenderErrBase + BadPictFormat);
+    SetResourceTypeErrorValue(GlyphSetType, RenderErrBase + BadGlyphSet);
 }
 
 static int
@@ -532,7 +543,7 @@ ProcRenderQueryPictIndexValues (ClientPtr client)
     rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format,
 				 PictFormatType, client, DixReadAccess);
     if (rc != Success)
-	return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+	return rc;
 
     if (pFormat->type != PictTypeIndexed)
     {
@@ -601,7 +612,7 @@ ProcRenderCreatePicture (ClientPtr client)
     rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format,
 				 PictFormatType, client, DixReadAccess);
     if (rc != Success)
-	return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+	return rc;
 
     if (pFormat->depth != pDrawable->depth)
 	return BadMatch;
@@ -760,7 +771,7 @@ ProcRenderTrapezoids (ClientPtr client)
 	rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
 				     PictFormatType, client, DixReadAccess);
 	if (rc != Success)
-	    return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+	    return rc;
     }
     else
 	pFormat = 0;
@@ -800,7 +811,7 @@ ProcRenderTriangles (ClientPtr client)
 	rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
 				     PictFormatType, client, DixReadAccess);
 	if (rc != Success)
-	    return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+	    return rc;
     }
     else
 	pFormat = 0;
@@ -840,7 +851,7 @@ ProcRenderTriStrip (ClientPtr client)
 	rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
 				     PictFormatType, client, DixReadAccess);
 	if (rc != Success)
-	    return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+	    return rc;
     }
     else
 	pFormat = 0;
@@ -880,7 +891,7 @@ ProcRenderTriFan (ClientPtr client)
 	rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
 				     PictFormatType, client, DixReadAccess);
 	if (rc != Success)
-	    return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+	    return rc;
     }
     else
 	pFormat = 0;
@@ -927,7 +938,7 @@ ProcRenderCreateGlyphSet (ClientPtr client)
     rc = dixLookupResourceByType((pointer *)&format, stuff->format,
 				 PictFormatType, client, DixReadAccess);
     if (rc != Success)
-	return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+	return rc;
 
     switch (format->depth) {
     case 1:
@@ -979,7 +990,7 @@ ProcRenderReferenceGlyphSet (ClientPtr client)
     if (rc != Success)
     {
 	client->errorValue = stuff->existing;
-	return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
+	return rc;
     }
     glyphSet->refcnt++;
     if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet))
@@ -1003,7 +1014,7 @@ ProcRenderFreeGlyphSet (ClientPtr client)
     if (rc != Success)
     {
 	client->errorValue = stuff->glyphset;
-	return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
+	return rc;
     }
     FreeResource (stuff->glyphset, RT_NONE);
     return client->noClientException;
@@ -1042,7 +1053,7 @@ ProcRenderAddGlyphs (ClientPtr client)
     if (err != Success)
     {
 	client->errorValue = stuff->glyphset;
-	return (err == BadValue) ? RenderErrBase + BadGlyphSet : err;
+	return err;
     }
 
     err = BadAlloc;
@@ -1236,7 +1247,7 @@ ProcRenderFreeGlyphs (ClientPtr client)
     if (rc != Success)
     {
 	client->errorValue = stuff->glyphset;
-	return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
+	return rc;
     }
     nglyph = bytes_to_int32((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq));
     gids = (CARD32 *) (stuff + 1);
@@ -1298,7 +1309,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
 	rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
 				     PictFormatType, client, DixReadAccess);
 	if (rc != Success)
-	    return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+	    return rc;
     }
     else
 	pFormat = 0;
@@ -1306,7 +1317,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
     rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset,
 				 GlyphSetType, client, DixUseAccess);
     if (rc != Success)
-	return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
+	return rc;
 
     buffer = (CARD8 *) (stuff + 1);
     end = (CARD8 *) stuff + (client->req_len << 2);
@@ -1369,7 +1380,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
 			xfree (glyphsBase);
 		    if (listsBase != listsLocal)
 			xfree (listsBase);
-		    return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
+		    return rc;
 		}
 	    }
 	    buffer += 4;
@@ -2642,7 +2653,7 @@ SProcRenderDispatch (ClientPtr client)
     int rc = dixLookupResourceByType((pointer *)&(pPicture), pid,\
                                      XRT_PICTURE, client, mode);\
     if (rc != Success)\
-	return (rc == BadValue) ? RenderErrBase + BadPicture : rc;\
+	return rc;\
 }
 
 #define VERIFY_XIN_ALPHA(pPicture, pid, client, mode) {\
@@ -2655,8 +2666,6 @@ SProcRenderDispatch (ClientPtr client)
 
 int	    (*PanoramiXSaveRenderVector[RenderNumberRequests])(ClientPtr);
 
-unsigned long	XRT_PICTURE;
-
 static int
 PanoramiXRenderCreatePicture (ClientPtr client)
 {
@@ -3333,6 +3342,8 @@ PanoramiXRenderInit (void)
     
     XRT_PICTURE = CreateNewResourceType (XineramaDeleteResource,
 					 "XineramaPicture");
+    if (RenderErrBase)
+	SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture);
     for (i = 0; i < RenderNumberRequests; i++)
 	PanoramiXSaveRenderVector[i] = ProcRenderVector[i];
     /*
@@ -3368,6 +3379,7 @@ PanoramiXRenderReset (void)
     int	    i;
     for (i = 0; i < RenderNumberRequests; i++)
 	ProcRenderVector[i] = PanoramiXSaveRenderVector[i];
+    RenderErrBase = 0;
 }
 
 #endif	/* PANORAMIX */
diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index 5163dc1..920f941 100644
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -259,5 +259,6 @@ XFixesExtensionInit(void)
 	    (EventSwapPtr) SXFixesSelectionNotifyEvent;
 	EventSwapVector[XFixesEventBase + XFixesCursorNotify] =
 	    (EventSwapPtr) SXFixesCursorNotifyEvent;
+	SetResourceTypeErrorValue(RegionResType, XFixesErrorBase + BadRegion);
     }
 }
diff --git a/xfixes/xfixes.h b/xfixes/xfixes.h
index 69d162f..1638350 100644
--- a/xfixes/xfixes.h
+++ b/xfixes/xfixes.h
@@ -37,10 +37,7 @@ extern _X_EXPORT int XFixesErrorBase;
 	int err;							\
 	err = dixLookupResourceByType((pointer *) &pRegion, rid,	\
 				      RegionResType, client, mode);	\
-	if (err == BadValue) {						\
-	    client->errorValue = rid;					\
-	    return XFixesErrorBase + BadRegion;				\
-	} else if (err != Success) {					\
+	if (err != Success) {						\
 	    client->errorValue = rid;					\
 	    return err;							\
 	}								\
-- 
1.7.0



More information about the xorg-devel mailing list