IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 1, 2006, 2:55:23 PM (20 years ago)
Author:
Paul Price
Message:

Addition of a vast quantity of assertions in public functions. Adopted a policy of using assert() within file-static functions (since they are only called internally, any errors there are problems with the program) and using the PS_ASSERT_WHATEVER() macros within public functions. Cleaned a few things up in the process.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.c

    r7187 r7278  
    33 *  @author PAP, IfA
    44 *
    5  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-05-23 23:37:23 $
     5 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-06-02 00:55:22 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6969    const char *description)            // Description of file
    7070{
     71    assert(config);
     72    assert(name && strlen(name) > 0);
     73    assert(description && strlen(description) > 0);
     74
    7175    char *realName = NULL;
    7276    unsigned int numBadLines = 0;
     
    303307        }
    304308        if (logFD == STDIN_FILENO) {
    305             psLogMsg(__func__, PS_LOG_WARN, "Only STDERR and STDOUT currently supported as a log destination.\n");
     309            psLogMsg(__func__, PS_LOG_WARN, "Only STDERR and STDOUT currently supported as a log "
     310                     "destination.\n");
    306311            logFD = STDERR_FILENO;
    307312        }
     
    352357    const psMetadata *header)
    353358{
     359    PS_ASSERT_PTR_NON_NULL(cameraFormat, false);
     360    PS_ASSERT_PTR_NON_NULL(header, false);
     361
    354362    // Read the rule for that camera format
    355363    bool mdStatus = true;
     
    395403    assert(camera);
    396404    assert(header);
     405    assert(cameraName && strlen(cameraName) > 0);
    397406
    398407    bool result = false;                // Did we find the first match?
     
    449458)
    450459{
     460    PS_ASSERT_PTR_NON_NULL(config, NULL);
     461    PS_ASSERT_PTR_NON_NULL(header, NULL);
     462
    451463    psMetadata *format = NULL;          // The winning format
    452464    bool mdok = false;                  // Metadata lookup status
     
    562574)
    563575{
     576    PS_ASSERT_PTR_NON_NULL(config, NULL);
     577    PS_ASSERT_PTR_NON_NULL(config->site, NULL);
     578
    564579    #ifdef OMIT_PSDB
     580
    565581    return NULL;
    566582    #else
    567583
    568     PS_ASSERT_PTR_NON_NULL(config->site, NULL);
    569584    psBool mdStatus01 = false;
    570585    psBool mdStatus02 = false;
     
    590605                          )
    591606{
     607    PS_ASSERT_PTR_NON_NULL(header, false);
     608    PS_ASSERT_PTR_NON_NULL(format, false);
     609
    592610    bool mdok = true;                   // Status of MD lookup
    593611    psMetadata *rules = psMetadataLookupMD(&mdok, format, "RULE"); // How to identify this format
     
    613631psArray *pmConfigFileSets (int *argc, char **argv, char *file, char *list)
    614632{
     633    PS_ASSERT_PTR_NON_NULL(argc, NULL);
     634    PS_ASSERT_INT_NONNEGATIVE(*argc, NULL);
     635    PS_ASSERT_PTR_NON_NULL(argv, NULL);
     636    PS_ASSERT_PTR_NON_NULL(file, NULL);
     637    PS_ASSERT_INT_POSITIVE(strlen(file), NULL);
     638    PS_ASSERT_PTR_NON_NULL(list, NULL);
     639    PS_ASSERT_INT_POSITIVE(strlen(list), NULL);
    615640
    616641    int Narg;
     
    670695bool pmConfigFileSetsMD (psMetadata *metadata, int *argc, char **argv, char *name, char *file, char *list)
    671696{
     697    PS_ASSERT_PTR_NON_NULL(metadata, false);
     698    PS_ASSERT_PTR_NON_NULL(argc, false);
     699    PS_ASSERT_INT_NONNEGATIVE(*argc, NULL);
     700    PS_ASSERT_PTR_NON_NULL(argv, false);
     701    PS_ASSERT_PTR_NON_NULL(name, false);
     702    PS_ASSERT_INT_POSITIVE(strlen(name), NULL);
     703    PS_ASSERT_PTR_NON_NULL(file, false);
     704    PS_ASSERT_INT_POSITIVE(strlen(file), NULL);
     705    PS_ASSERT_PTR_NON_NULL(list, false);
     706    PS_ASSERT_INT_POSITIVE(strlen(list), NULL);
    672707
    673708    psArray *files = pmConfigFileSets (argc, argv, file, list);
Note: See TracChangeset for help on using the changeset viewer.