Index: /trunk/ippTools/src/difftool.c
===================================================================
--- /trunk/ippTools/src/difftool.c	(revision 11852)
+++ /trunk/ippTools/src/difftool.c	(revision 11853)
@@ -53,4 +53,8 @@
 
     pxConfig *config = p5toolConfig(NULL, argc, argv);
+    if (!config) {
+        psError(PXTOOLS_ERR_CONFIG, false, "failed to configure");
+        goto FAIL;
+    }
 
     switch (config->mode) {
@@ -74,4 +78,5 @@
 FAIL:
     psErrorStackPrint(stderr, "\n");
+    int exit_status = pxerrorGetExitStatus();
 
     psFree(config);
@@ -79,5 +84,5 @@
     psLibFinalize();
 
-    exit(EXIT_FAILURE);
+    exit(exit_status);
 }
 
Index: /trunk/ippTools/src/difftoolConfig.c
===================================================================
--- /trunk/ippTools/src/difftoolConfig.c	(revision 11852)
+++ /trunk/ippTools/src/difftoolConfig.c	(revision 11853)
@@ -27,6 +27,6 @@
 #include "p5tool.h"
 
-// this function can not fail -- exits on error
-pxConfig *p5toolConfig(pxConfig *config, int argc, char **argv) {
+pxConfig *p5toolConfig(pxConfig *config, int argc, char **argv)
+{
     if (!config) {
         config = pxConfigAlloc();
@@ -39,5 +39,6 @@
     if (!config->modules) {
         psError(PS_ERR_UNKNOWN, false, "Can't find site configuration");
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -148,5 +149,6 @@
         if (config->mode) { \
             psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed"); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
         config->mode = modeval; \
@@ -196,5 +198,6 @@
 
         psFree(argSets);
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -209,5 +212,6 @@
         if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
     } \
@@ -221,5 +225,6 @@
         if (!psMetadataAddS32(config->where, PS_LIST_TAIL, #name, 0, "==", s32)) { \
             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
     } \
@@ -236,5 +241,6 @@
         if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p5_id", 0, "==", (psS32)atoi(str))) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item p5_id");
-            goto FAIL; 
+            psFree(config);
+            return NULL;
         } 
     } 
@@ -246,5 +252,6 @@
         if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p4_id", 0, "==", (psS32)atoi(str))) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id");
-            goto FAIL; 
+            psFree(config);
+            return NULL;
         } 
     } 
@@ -264,5 +271,6 @@
     if (!config->dbh) {
         psError(PS_ERR_UNKNOWN, false, "Can't configure database");
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -272,9 +280,3 @@
 
     return config;
-
-FAIL:
-    psFree(config);
-    pmConfigDone();
-    psLibFinalize();
-    exit(EXIT_FAILURE);
-}
+}
