IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

properly handle pztoolConfig() errors

File:
1 edited

Legend:

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

    r11702 r11860  
    2727#include "pztool.h"
    2828
    29 // this function can not fail -- exits on error
    30 pxConfig *pztoolConfig(pxConfig *config, int argc, char **argv) {
     29pxConfig *pztoolConfig(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!\n");
    41         exit(EXIT_FAILURE);
     41        psFree(config);
     42        return NULL;
    4243    }
    4344
     
    103104        if (config->mode) { \
    104105            psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed"); \
    105             goto FAIL; \
     106            psFree(config); \
     107            return NULL; \
    106108        } \
    107109        config->mode = modeval; \
     
    148150
    149151        psFree(argSets);
    150         goto FAIL;
     152        psFree(config);
     153        return NULL;
    151154    }
    152155
     
    161164        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
    162165            psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
    163             goto FAIL; \
     166            psFree(config); \
     167            return NULL; \
    164168        } \
    165169    } \
     
    178182            if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
    179183                psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
    180                 goto FAIL;
     184                psFree(config);
     185                return NULL;
    181186            }
    182187        }
     
    197202    if (!config->dbh) {
    198203        psError(PS_ERR_UNKNOWN, false, "Can't configure database");
    199         goto FAIL;
     204        psFree(config);
     205        return NULL;
    200206    }
    201207
     
    205211
    206212    return config;
    207 
    208 FAIL:
    209     psFree(config);
    210     pmConfigDone();
    211     psLibFinalize();
    212     exit(EXIT_FAILURE);
    213213}
Note: See TracChangeset for help on using the changeset viewer.