IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11853


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

properly handle p5toolConfig() errors

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

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

    r11818 r11853  
    5353
    5454    pxConfig *config = p5toolConfig(NULL, argc, argv);
     55    if (!config) {
     56        psError(PXTOOLS_ERR_CONFIG, false, "failed to configure");
     57        goto FAIL;
     58    }
    5559
    5660    switch (config->mode) {
     
    7478FAIL:
    7579    psErrorStackPrint(stderr, "\n");
     80    int exit_status = pxerrorGetExitStatus();
    7681
    7782    psFree(config);
     
    7984    psLibFinalize();
    8085
    81     exit(EXIT_FAILURE);
     86    exit(exit_status);
    8287}
    8388
  • trunk/ippTools/src/difftoolConfig.c

    r11818 r11853  
    2727#include "p5tool.h"
    2828
    29 // this function can not fail -- exits on error
    30 pxConfig *p5toolConfig(pxConfig *config, int argc, char **argv) {
     29pxConfig *p5toolConfig(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
     
    148149        if (config->mode) { \
    149150            psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed"); \
    150             goto FAIL; \
     151            psFree(config); \
     152            return NULL; \
    151153        } \
    152154        config->mode = modeval; \
     
    196198
    197199        psFree(argSets);
    198         goto FAIL;
     200        psFree(config);
     201        return NULL;
    199202    }
    200203
     
    209212        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
    210213            psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
    211             goto FAIL; \
     214            psFree(config); \
     215            return NULL; \
    212216        } \
    213217    } \
     
    221225        if (!psMetadataAddS32(config->where, PS_LIST_TAIL, #name, 0, "==", s32)) { \
    222226            psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
    223             goto FAIL; \
     227            psFree(config); \
     228            return NULL; \
    224229        } \
    225230    } \
     
    236241        if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p5_id", 0, "==", (psS32)atoi(str))) {
    237242            psError(PS_ERR_UNKNOWN, false, "failed to add item p5_id");
    238             goto FAIL;
     243            psFree(config);
     244            return NULL;
    239245        }
    240246    }
     
    246252        if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p4_id", 0, "==", (psS32)atoi(str))) {
    247253            psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id");
    248             goto FAIL;
     254            psFree(config);
     255            return NULL;
    249256        }
    250257    }
     
    264271    if (!config->dbh) {
    265272        psError(PS_ERR_UNKNOWN, false, "Can't configure database");
    266         goto FAIL;
     273        psFree(config);
     274        return NULL;
    267275    }
    268276
     
    272280
    273281    return config;
    274 
    275 FAIL:
    276     psFree(config);
    277     pmConfigDone();
    278     psLibFinalize();
    279     exit(EXIT_FAILURE);
    280 }
     282}
Note: See TracChangeset for help on using the changeset viewer.