Index: /trunk/ippTools/src/regtool.c
===================================================================
--- /trunk/ippTools/src/regtool.c	(revision 11841)
+++ /trunk/ippTools/src/regtool.c	(revision 11842)
@@ -56,9 +56,11 @@
 int main(int argc, char **argv)
 {
-    psExit exit_status = PS_EXIT_SUCCESS;
-
     psLibInit(NULL);
 
     pxConfig *config = p0toolConfig(NULL, argc, argv);
+    if (!config) {
+        psError(PXTOOLS_ERR_CONFIG, false, "failed to configure");
+        goto FAIL;
+    }
 
     switch (config->mode) {
@@ -79,13 +81,12 @@
     psLibFinalize();
 
-    exit(exit_status);
+    exit(EXIT_SUCCESS);
 
 FAIL:
-    // use the top-most error to determine the exit status
-    exit_status = pxerrorGetExitStatus();
+    psErrorStackPrint(stderr, "\n");
+    int exit_status = pxerrorGetExitStatus();
 
     psFree(config);
     pmConfigDone();
-    psErrorStackPrint(stderr, "\n");
     psLibFinalize();
 
Index: /trunk/ippTools/src/regtoolConfig.c
===================================================================
--- /trunk/ippTools/src/regtoolConfig.c	(revision 11841)
+++ /trunk/ippTools/src/regtoolConfig.c	(revision 11842)
@@ -28,9 +28,6 @@
 #include "p0tool.h"
 
-// this function can not fail -- exits on error
-pxConfig *p0toolConfig(pxConfig *config, int argc, char **argv) {
-
-    psExit exit_status = PS_EXIT_SUCCESS;
-
+pxConfig *p0toolConfig(pxConfig *config, int argc, char **argv)
+{
     if (!config) {
         config = pxConfigAlloc();
@@ -43,5 +40,6 @@
     if (!config->modules) {
         psError(PXTOOLS_ERR_CONFIG, false, "Can't find site configuration");
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -217,5 +215,6 @@
         if (config->mode) { \
             psError(PXTOOLS_ERR_CONFIG, true, "only one mode selection is allowed"); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
         config->mode = modeval; \
@@ -267,5 +266,6 @@
 
         psFree(argSets);
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -280,5 +280,6 @@
         if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
             psError(PXTOOLS_ERR_PROG, false, "failed to add item " #name); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
     } \
@@ -296,5 +297,6 @@
             if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
                 psError(PXTOOLS_ERR_PROG, false, "failed to add item camera");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -308,5 +310,6 @@
             if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", imfiles)) {
                 psError(PXTOOLS_ERR_PROG, false, "failed to add item imfiles");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -326,5 +329,6 @@
     if (!config->dbh) {
         psError(PXTOOLS_ERR_SYS, false, "Can't configure database");
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -333,14 +337,4 @@
     config->argc = argc;
 
-
     return config;
-
-FAIL:
-    // use the top-most error to determine the exit status
-    exit_status = pxerrorGetExitStatus();
-
-    psFree(config);
-    pmConfigDone();
-    psLibFinalize();
-    exit(exit_status);
 }
