IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2291


Ignore:
Timestamp:
Nov 5, 2004, 2:44:56 PM (22 years ago)
Author:
gusciora
Message:

Removed redundant type checking.

Location:
trunk/psLib/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/psConstants.h

    r2274 r2291  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-11-04 01:59:04 $
     8 *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-06 00:44:56 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4141    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
    4242            "Error: %s is 0 or less.", #NAME); \
     43    return(RVAL); \
     44}
     45
     46#define PS_INT_CHECK_ZERO(NAME, RVAL) \
     47if (NAME < 1) { \
     48    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     49            "Error: %s is 0.", #NAME); \
    4350    return(RVAL); \
    4451}
  • trunk/psLib/src/image/psImage.c

    r2273 r2291  
    1 
    21/** @file  psImage.c
    32 *
     
    109 *  @author Ross Harman, MHPCC
    1110 *
    12  *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-11-04 01:05:00 $
     11 *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-06 00:44:56 $
    1413 *
    1514 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  • trunk/psLib/src/image/psImageStats.c

    r2273 r2291  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-04 01:05:00 $
     11 *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-06 00:44:56 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4242                      psS32 maskVal)
    4343{
     44    PS_PTR_CHECK_NULL(stats, NULL);
     45    PS_INT_CHECK_ZERO(stats->options, NULL);
     46    PS_IMAGE_CHECK_NULL(in, NULL)
    4447    psVector* junkData = NULL;
    4548    psVector* junkMask = NULL;
    4649
    47     if (stats == NULL) {
    48         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    49                 PS_ERRORTEXT_psImage_STAT_NULL);
    50         return NULL;
    51     }
    52 
    53     if (in == NULL) {
    54         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    55                 PS_ERRORTEXT_psImage_IMAGE_NULL);
    56         return NULL;
    57     }
    58 
    59     if (stats->options == 0) {
    60         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    61                 PS_ERRORTEXT_psImage_NO_STAT_OPTIONS);
    62         return stats;
    63     }
    6450    // stuff the image data into a psVector struct.
    6551    junkData = psAlloc(sizeof(psVector));
     
    9783    NOTE: We assume that the psHistogram structure out has already been
    9884    allocated and initialized.
    99     NOTE: verify that image/mask have the correct types and sizes.
    10085 *****************************************************************************/
    10186psHistogram* psImageHistogram(psHistogram* out,
     
    10489                              psU32 maskVal)
    10590{
     91    PS_PTR_CHECK_NULL(out, NULL);
     92    PS_PTR_CHECK_NULL(in, NULL);
     93    if (mask != NULL) {
     94        PS_IMAGE_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
     95    }
    10696    psVector* junkData = NULL;
    10797    psVector* junkMask = NULL;
    108 
    109     // NOTE: Verify this action.
    110     PS_PTR_CHECK_NULL(out, NULL);
    111     PS_PTR_CHECK_NULL(in, NULL);
    11298
    11399    junkData = psAlloc(sizeof(psVector));
     
    118104
    119105    if (mask != NULL) {
    120         if (mask->type.type != PS_TYPE_MASK) {
    121             char* typeStr;
    122             PS_TYPE_NAME(typeStr,mask->type.type);
    123             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    124                     PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
    125                     typeStr, PS_TYPE_MASK_NAME);
    126             psFree(out);
    127             psFree(junkData);
    128             return NULL;
    129         }
    130106        // stuff the mask data into a psVector struct.
    131107        junkMask = psAlloc(sizeof(psVector));
     
    187163psPolynomial1D **p_psCreateChebyshevPolys(psS32 maxChebyPoly)
    188164{
    189     if (maxChebyPoly < 1) {
    190         return(NULL);
    191     }
     165    PS_INT_CHECK_POSITIVE(maxChebyPoly, NULL);
    192166    psPolynomial1D **chebPolys = NULL;
    193167    psS32 i = 0;
     
    238212            (input->type.type != PS_TYPE_F32) &&
    239213            (input->type.type != PS_TYPE_F64)) {
    240         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    241                 "Unallowable image type.\n");
     214        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unallowable image type.\n");
    242215    }
    243216    PS_POLY_CHECK_NULL(coeffs, NULL);
     
    252225    double *cScalingFactors = NULL;
    253226    double *rScalingFactors = NULL;
    254 
    255     // Check for null inputs
    256     if (input == NULL) {
    257         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    258                 PS_ERRORTEXT_psImage_IMAGE_NULL);
    259         return NULL;
    260     }
    261 
    262     if (coeffs == NULL) {
    263         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    264                 PS_ERRORTEXT_psImage_COEFF_NULL);
    265         return NULL;
    266     }
    267227
    268228    // Create the sums[][] data structure.  This
     
    287247    }
    288248    chebPolys = p_psCreateChebyshevPolys(maxChebyPoly);
    289 
    290249
    291250    // Compute the sums[][] data structure.
     
    373332    float polySum = 0.0;
    374333
    375     // Check for null inputs
    376     if (input == NULL) {
    377         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    378                 PS_ERRORTEXT_psImage_IMAGE_NULL);
    379         return NULL;
    380     }
    381 
    382     if (coeffs == NULL) {
    383         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    384                 PS_ERRORTEXT_psImage_COEFF_NULL);
    385         return NULL;
    386     }
    387 
    388334    // We scale the pixel positions to values between -1.0 and 1.0
    389335    // Use static data structures here.
  • trunk/psLib/src/imageops/psImageStats.c

    r2273 r2291  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-04 01:05:00 $
     11 *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-06 00:44:56 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4242                      psS32 maskVal)
    4343{
     44    PS_PTR_CHECK_NULL(stats, NULL);
     45    PS_INT_CHECK_ZERO(stats->options, NULL);
     46    PS_IMAGE_CHECK_NULL(in, NULL)
    4447    psVector* junkData = NULL;
    4548    psVector* junkMask = NULL;
    4649
    47     if (stats == NULL) {
    48         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    49                 PS_ERRORTEXT_psImage_STAT_NULL);
    50         return NULL;
    51     }
    52 
    53     if (in == NULL) {
    54         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    55                 PS_ERRORTEXT_psImage_IMAGE_NULL);
    56         return NULL;
    57     }
    58 
    59     if (stats->options == 0) {
    60         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    61                 PS_ERRORTEXT_psImage_NO_STAT_OPTIONS);
    62         return stats;
    63     }
    6450    // stuff the image data into a psVector struct.
    6551    junkData = psAlloc(sizeof(psVector));
     
    9783    NOTE: We assume that the psHistogram structure out has already been
    9884    allocated and initialized.
    99     NOTE: verify that image/mask have the correct types and sizes.
    10085 *****************************************************************************/
    10186psHistogram* psImageHistogram(psHistogram* out,
     
    10489                              psU32 maskVal)
    10590{
     91    PS_PTR_CHECK_NULL(out, NULL);
     92    PS_PTR_CHECK_NULL(in, NULL);
     93    if (mask != NULL) {
     94        PS_IMAGE_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
     95    }
    10696    psVector* junkData = NULL;
    10797    psVector* junkMask = NULL;
    108 
    109     // NOTE: Verify this action.
    110     PS_PTR_CHECK_NULL(out, NULL);
    111     PS_PTR_CHECK_NULL(in, NULL);
    11298
    11399    junkData = psAlloc(sizeof(psVector));
     
    118104
    119105    if (mask != NULL) {
    120         if (mask->type.type != PS_TYPE_MASK) {
    121             char* typeStr;
    122             PS_TYPE_NAME(typeStr,mask->type.type);
    123             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    124                     PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
    125                     typeStr, PS_TYPE_MASK_NAME);
    126             psFree(out);
    127             psFree(junkData);
    128             return NULL;
    129         }
    130106        // stuff the mask data into a psVector struct.
    131107        junkMask = psAlloc(sizeof(psVector));
     
    187163psPolynomial1D **p_psCreateChebyshevPolys(psS32 maxChebyPoly)
    188164{
    189     if (maxChebyPoly < 1) {
    190         return(NULL);
    191     }
     165    PS_INT_CHECK_POSITIVE(maxChebyPoly, NULL);
    192166    psPolynomial1D **chebPolys = NULL;
    193167    psS32 i = 0;
     
    238212            (input->type.type != PS_TYPE_F32) &&
    239213            (input->type.type != PS_TYPE_F64)) {
    240         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    241                 "Unallowable image type.\n");
     214        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unallowable image type.\n");
    242215    }
    243216    PS_POLY_CHECK_NULL(coeffs, NULL);
     
    252225    double *cScalingFactors = NULL;
    253226    double *rScalingFactors = NULL;
    254 
    255     // Check for null inputs
    256     if (input == NULL) {
    257         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    258                 PS_ERRORTEXT_psImage_IMAGE_NULL);
    259         return NULL;
    260     }
    261 
    262     if (coeffs == NULL) {
    263         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    264                 PS_ERRORTEXT_psImage_COEFF_NULL);
    265         return NULL;
    266     }
    267227
    268228    // Create the sums[][] data structure.  This
     
    287247    }
    288248    chebPolys = p_psCreateChebyshevPolys(maxChebyPoly);
    289 
    290249
    291250    // Compute the sums[][] data structure.
     
    373332    float polySum = 0.0;
    374333
    375     // Check for null inputs
    376     if (input == NULL) {
    377         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    378                 PS_ERRORTEXT_psImage_IMAGE_NULL);
    379         return NULL;
    380     }
    381 
    382     if (coeffs == NULL) {
    383         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    384                 PS_ERRORTEXT_psImage_COEFF_NULL);
    385         return NULL;
    386     }
    387 
    388334    // We scale the pixel positions to values between -1.0 and 1.0
    389335    // Use static data structures here.
  • trunk/psLib/src/math/psConstants.h

    r2274 r2291  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-11-04 01:59:04 $
     8 *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-06 00:44:56 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4141    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
    4242            "Error: %s is 0 or less.", #NAME); \
     43    return(RVAL); \
     44}
     45
     46#define PS_INT_CHECK_ZERO(NAME, RVAL) \
     47if (NAME < 1) { \
     48    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     49            "Error: %s is 0.", #NAME); \
    4350    return(RVAL); \
    4451}
  • trunk/psLib/src/mathtypes/psImage.c

    r2273 r2291  
    1 
    21/** @file  psImage.c
    32 *
     
    109 *  @author Ross Harman, MHPCC
    1110 *
    12  *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-11-04 01:05:00 $
     11 *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-06 00:44:56 $
    1413 *
    1514 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
Note: See TracChangeset for help on using the changeset viewer.