IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 15, 2007, 3:59:13 PM (19 years ago)
Author:
jhoblitt
Message:

properly handle p3toolConfig() errors

File:
1 edited

Legend:

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

    r11771 r11844  
    2828#include "p3tool.h"
    2929
    30 // this function can not fail -- exits on error
    31 pxConfig *p3toolConfig(pxConfig *config, int argc, char **argv) {
     30pxConfig *p3toolConfig(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
     
    150151        if (config->mode) { \
    151152            psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed"); \
    152             goto FAIL; \
     153            psFree(config); \
     154            return NULL; \
    153155        } \
    154156        config->mode = modeval; \
     
    198200
    199201        psFree(argSets);
    200         goto FAIL;
     202        psFree(config);
     203        return NULL;
    201204    }
    202205
     
    211214        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
    212215            psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
    213             goto FAIL; \
     216            psFree(config); \
     217            return NULL; \
    214218        } \
    215219    } \
     
    227231            if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
    228232                psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
    229                 goto FAIL;
     233                psFree(config);
     234                return NULL;
    230235            }
    231236        }
     
    239244            if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", imfiles)) {
    240245                psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");
    241                 goto FAIL;
     246                psFree(config);
     247                return NULL;
    242248            }
    243249        }
     
    257263    if (!config->dbh) {
    258264        psError(PS_ERR_UNKNOWN, false, "Can't configure database");
    259         goto FAIL;
     265        psFree(config);
     266        return NULL;
    260267    }
    261268
     
    264271    config->argc = argc;
    265272
    266 
    267273    return config;
    268 
    269 FAIL:
    270     psFree(config);
    271     pmConfigDone();
    272     psLibFinalize();
    273     exit(EXIT_FAILURE);
    274274}
Note: See TracChangeset for help on using the changeset viewer.