IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11854


Ignore:
Timestamp:
Feb 16, 2007, 12:17:05 PM (19 years ago)
Author:
jhoblitt
Message:

properly handle pxinjectConfig() errors

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/pxinject.c

    r11702 r11854  
    4444
    4545    pxConfig *config = pxinjectConfig(NULL, argc, argv);
     46    if (!config) {
     47        psError(PXTOOLS_ERR_CONFIG, false, "failed to configure");
     48        goto FAIL;
     49    }
    4650
    4751    switch (config->mode) {
     
    6064FAIL:
    6165    psErrorStackPrint (stderr, "failure\n");
     66    int exit_status = pxerrorGetExitStatus();
    6267
    6368    psFree(config);
     
    6570    psLibFinalize();
    6671
    67     exit(EXIT_FAILURE);
     72    exit(exit_status);
    6873}
    6974
  • trunk/ippTools/src/pxinjectConfig.c

    r11142 r11854  
    2727#include "pxinject.h"
    2828
    29 // this function can not fail -- exits on error
    30 pxConfig *pxinjectConfig(pxConfig *config, int argc, char **argv) {
     29pxConfig *pxinjectConfig(pxConfig *config, int argc, char **argv)
     30{
    3131    if (!config) {
    3232        config = pxConfigAlloc();
     
    3939    if (!config->modules) {
    4040        psError(PS_ERR_UNKNOWN, false, "Can't find site configuration");
    41         goto FAIL;
     41        psFree(config);
     42        return NULL;
    4243    }
    4344
     
    105106        psFree(newImfileArgs);
    106107
    107         goto FAIL;
     108        psFree(config);
     109        return NULL;
    108110    }
    109111
     
    119121        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
    120122            psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
    121             goto FAIL; \
     123            psFree(config); \
     124            return NULL; \
    122125        } \
    123126    } \
     
    134137            if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "iteration", 0, "==", n)) {
    135138                psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
    136                 goto FAIL;
     139                psFree(config);
     140                return NULL;
    137141            }
    138142        }
     
    148152            if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
    149153                psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
    150                 goto FAIL;
     154                psFree(config);
     155                return NULL;
    151156            }
    152157        }
     
    159164            if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", n)) {
    160165                psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");
    161                 goto FAIL;
     166                psFree(config);
     167                return NULL;
    162168            }
    163169        }
     
    172178            if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p1_version", 0, "==", n)) {
    173179                psError(PS_ERR_UNKNOWN, false, "failed to add item p1_version");
    174                 goto FAIL;
     180                psFree(config);
     181                return NULL;
    175182            }
    176183        }
     
    183190            if (!psMetadataAddBool(config->where, PS_LIST_TAIL, "accept", 0, "==", boolean)) {
    184191                psError(PS_ERR_UNKNOWN, false, "failed to add item accept");
    185                 goto FAIL;
     192                psFree(config);
     193                return NULL;
    186194            }
    187195        }
     
    199207    if (!config->dbh) {
    200208        psError(PS_ERR_UNKNOWN, false, "Can't configure database");
    201         goto FAIL;
     209        psFree(config);
     210        return NULL;
    202211    }
    203212
     
    207216
    208217    return config;
    209 
    210 FAIL:
    211     psFree(config);
    212     pmConfigDone();
    213     psLibFinalize();
    214     exit(EXIT_FAILURE);
    215218}
Note: See TracChangeset for help on using the changeset viewer.