IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11856


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

properly handle detselectConfig() errors

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

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

    r11713 r11856  
    4242
    4343    pxConfig *config = detselectConfig(NULL, argc, argv);
     44    if (!config) {
     45        psError(PXTOOLS_ERR_CONFIG, false, "failed to configure");
     46        goto FAIL;
     47    }
    4448
    4549    switch (config->mode) {
     
    5761
    5862FAIL:
     63    psErrorStackPrint(stderr, "\n");
     64    int exit_status = pxerrorGetExitStatus();
     65
    5966    psFree(config);
    6067    pmConfigDone();
    61     psErrorStackPrint(stderr, "\n");
    6268    psLibFinalize();
    6369
    64     exit(EXIT_FAILURE);
     70    exit(exit_status);
    6571}
    6672
  • trunk/ippTools/src/detselectConfig.c

    r11702 r11856  
    2828#include "detselect.h"
    2929
    30 // this function can not fail -- exits on error
    31 pxConfig *detselectConfig(pxConfig *config, int argc, char **argv) {
     30pxConfig *detselectConfig(pxConfig *config, int argc, char **argv)
     31{
    3232    if (!config) {
    3333        config = pxConfigAlloc();
     
    4040    if (!config->modules) {
    4141        psError(PS_ERR_UNKNOWN, false, "Can't find site configuration");
    42         goto FAIL;
     42        psFree(config);
     43        return NULL;
    4344    }
    4445
     
    8485        if (config->mode) { \
    8586            psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed"); \
    86             goto FAIL; \
     87            psFree(config); \
     88            return NULL; \
    8789        } \
    8890        config->mode = modeval; \
     
    126128
    127129        psFree(argSets);
    128         goto FAIL;
     130        psFree(config);
     131        return NULL;
    129132    }
    130133
     
    139142        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
    140143            psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
    141             goto FAIL; \
     144            psFree(config); \
     145            return NULL; \
    142146        } \
    143147    } \
     
    151155        if (!psMetadataAddS32(config->where, PS_LIST_TAIL, #name, 0, "==", s32)) { \
    152156            psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
    153             goto FAIL; \
     157            psFree(config); \
     158            return NULL; \
    154159        } \
    155160    } \
     
    164169            if (!psMetadataAddF32(config->where, PS_LIST_TAIL, #name, 0, "==", var)) { \
    165170                psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
    166                 goto FAIL; \
     171                psFree(config); \
     172                return NULL; \
    167173            } \
    168174        } \
     
    178184            if (!psMetadataAddF64(config->where, PS_LIST_TAIL, #name, 0, "==", var)) { \
    179185                psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
    180                 goto FAIL; \
     186                psFree(config); \
     187                return NULL; \
    181188            } \
    182189        } \
     
    192199        if (!time) { \
    193200            psError(PS_ERR_UNKNOWN, false, "failed to convert " #name " into a psTime object"); \
    194             goto FAIL; \
     201            psFree(config); \
     202            return NULL; \
    195203        } \
    196204        psMetadataItem *item = psMetadataLookup(config->args, "-" #name); \
     
    202210        if (!psMetadataAddTime(config->where, PS_LIST_TAIL, #name, 0, str, time)) {\
    203211            psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
    204             goto FAIL; \
     212            psFree(config); \
     213            return NULL; \
    205214        } \
    206215        psFree(time); \
     
    221230            if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
    222231                psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
    223                 goto FAIL;
     232                psFree(config);
     233                return NULL;
    224234            }
    225235        }
     
    248258    if (!config->dbh) {
    249259        psError(PS_ERR_UNKNOWN, false, "Can't configure database");
    250         goto FAIL;
     260        psFree(config);
     261        return NULL;
    251262    }
    252263
     
    256267
    257268    return config;
    258 
    259 FAIL:
    260     psFree(config);
    261     pmConfigDone();
    262     psLibFinalize();
    263 
    264     exit(EXIT_FAILURE);
    265 }
     269}
Note: See TracChangeset for help on using the changeset viewer.