[PATCH 1/2] SetFontPath: set client->errorValue on failure.

Jamey Sharp jamey at minilop.net
Tue May 11 10:24:00 PDT 2010


Previously the callers were only setting errorValue on Success, when
it's ignored, and leaving it alone on failure, when it's sent to the
client.

Since SetFontPath takes the ClientPtr, let it set client->errorValue
instead of letting the callers continue to get it wrong.

Signed-off-by: Jamey Sharp <jamey at minilop.net>
---
This commit applies fine against master, though this copy is based
against my pile of cleanup patches.

 dix/dispatch.c    |    7 +------
 dix/dixfonts.c    |    7 ++++---
 hw/dmx/dmxfont.c  |   16 +++++-----------
 include/dixfont.h |    3 +--
 4 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 5b96f08..b29395f 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -3391,7 +3391,6 @@ ProcSetFontPath(ClientPtr client)
     unsigned long nbytes, total;
     long nfonts;
     int n, result;
-    int error;
     REQUEST(xSetFontPathReq);
     
     REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
@@ -3409,13 +3408,9 @@ ProcSetFontPath(ClientPtr client)
     }
     if (total >= 4)
 	return(BadLength);
-    result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1],
-			 &error);
+    result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1]);
     if (!result)
-    {
 	result = client->noClientException;
-	client->errorValue = error;
-    }
     return (result);
 }
 
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 7d31762..fcb820a 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1793,9 +1793,8 @@ bail:
     return FontToXError(err);
 }
 
-/* XXX -- do we need to pass error down to each renderer? */
 int
-SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error)
+SetFontPath(ClientPtr client, int npaths, unsigned char *paths)
 {
     int err = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess);
     if (err != Success)
@@ -1805,7 +1804,9 @@ SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error)
 	if (SetDefaultFontPath(defaultFontPath) != Success)
 	    return BadValue;
     } else {
-	err = SetFontPathElements(npaths, paths, error, FALSE);
+	int bad;
+	err = SetFontPathElements(npaths, paths, &bad, FALSE);
+	client->errorValue = bad;
     }
     return err;
 }
diff --git a/hw/dmx/dmxfont.c b/hw/dmx/dmxfont.c
index c33aee7..3c2e902 100644
--- a/hw/dmx/dmxfont.c
+++ b/hw/dmx/dmxfont.c
@@ -172,7 +172,6 @@ static int dmxProcSetFontPath(ClientPtr client)
     unsigned long  nbytes, total, n;
     long           nfonts;
     int            i, result;
-    int            error;
     unsigned char *oldFontPath, *tmpFontPath;
     int            nOldPaths;
     int            lenOldPaths;
@@ -198,22 +197,19 @@ static int dmxProcSetFontPath(ClientPtr client)
     oldFontPath = xalloc(nOldPaths + lenOldPaths);
     memmove(oldFontPath, tmpFontPath, nOldPaths + lenOldPaths);
 
-    result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1],
-			 &error);
+    result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1]);
     if (!result) {
+	int error = 0;
 	for (i = 0; i < dmxNumScreens; i++)
 	    if ((result = dmxCheckFontPath(&dmxScreens[i], &error)))
 		break;
 
 	if (result) {
-	    int  ignoreresult, ignoreerror;
-
 	    /* Restore old fontpath in the DMX server */
-	    ignoreresult = SetFontPath(client, nOldPaths, oldFontPath,
-				       &ignoreerror);
+	    SetFontPath(client, nOldPaths, oldFontPath);
+	    client->errorValue = error;
 	} else {
 	    result = client->noClientException;
-	    client->errorValue = error;
 	}
     }
 
@@ -315,7 +311,6 @@ Bool dmxBELoadFont(ScreenPtr pScreen, FontPtr pFont)
 	    int   newnpaths = 0;
 	    int   len = 0;
 	    int   j = 0;
-	    int   error;
 
 	    dmxLog(dmxError,
 		   "These font paths will not be used because the "
@@ -361,8 +356,7 @@ Bool dmxBELoadFont(ScreenPtr pScreen, FontPtr pFont)
 		}
 	    }
 
-	    if (SetFontPath(serverClient, newnpaths, (unsigned char *)newfp,
-			    &error)) {
+	    if (SetFontPath(serverClient, newnpaths, (unsigned char *)newfp)) {
 		/* Note that this should never happen since all of the
 		 * FPEs were previously valid. */
 		dmxLog(dmxError, "Cannot reset the default font path.\n");
diff --git a/include/dixfont.h b/include/dixfont.h
index e444a20..cf86f54 100644
--- a/include/dixfont.h
+++ b/include/dixfont.h
@@ -96,8 +96,7 @@ extern _X_EXPORT int ImageText(ClientPtr /*client*/,
 
 extern _X_EXPORT int SetFontPath(ClientPtr /*client*/,
 		       int /*npaths*/,
-		       unsigned char * /*paths*/,
-		       int * /*error*/);
+		       unsigned char * /*paths*/);
 
 extern _X_EXPORT int SetDefaultFontPath(char * /*path*/);
 
-- 
1.7.0



More information about the xorg-devel mailing list