IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 27, 2004, 11:06:30 AM (22 years ago)
Author:
gusciora
Message:

Added parameter checking to psFunctions.c

File:
1 edited

Legend:

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

    r2216 r2217  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-27 20:32:49 $
     8 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-10-27 21:06:30 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828
    2929/*****************************************************************************
     30 
     31*****************************************************************************/
     32#define PS_INT_CHECK_NON_NEGATIVE(NAME, RVAL) \
     33if (NAME < 0) { \
     34    psError(__func__,"%s is less than 0.", #NAME); \
     35    return(RVAL); \
     36}
     37
     38
     39
     40/*****************************************************************************
    3041Macros which take a generic psLib type and determine if it is NULL, or has
    3142the wrong type.
     
    4859    PS_VECTOR macros:
    4960 *****************************************************************************/
    50 #define PS_VECTOR_CHECK_TYPE_F32_OR_F64(VEC, RVAL) \
    51 if ((VEC->type.type != PS_TYPE_F32) && (VEC->type.type != PS_TYPE_F64)) { \
    52     psAbort(__func__, "Bad type for VEC (%d)", VEC->type.type); \
     61#define PS_VECTOR_CHECK_NULL(NAME, RVAL) \
     62if (NAME == NULL || NAME->data.V == NULL) { \
     63    psError(__func__,"Unallowable operation: psVector %s or its data is NULL.", #NAME); \
     64    return(RVAL); \
     65} \
     66
     67#define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \
     68if (NAME->n < 1) { \
     69    psError(__func__,"Unallowable operation: psVector %s has no elements.", #NAME); \
     70    return(RVAL); \
     71} \
     72
     73#define PS_VECTOR_CHECK_TYPE_F32_OR_F64(NAME, RVAL) \
     74if ((NAME->type.type != PS_TYPE_F32) && (NAME->type.type != PS_TYPE_F64)) { \
     75    psAbort(__func__, "psVector %s: bad type(%d)", #NAME, NAME->type.type); \
    5376    return(RVAL); \
    5477} \
     
    5679#define PS_VECTOR_CHECK_TYPE(NAME, TYPE, RVAL) \
    5780if (NAME->type.type != TYPE) { \
    58     psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \
    59     return(RVAL); \
    60 }
    61 
    62 #define PS_VECTOR_CHECK_NULL(NAME, RVAL) \
    63 if (NAME == NULL || NAME->data.V == NULL) { \
    64     psError(__func__,"Unallowable operation: %s or its data is NULL.", #NAME); \
    65     return(RVAL); \
    66 } \
    67 
    68 #define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \
    69 if (NAME->n < 1) { \
    70     psError(__func__,"Unallowable operation: %s has zero n value.", #NAME); \
    71     return(RVAL); \
    72 } \
     81    psError(__func__,"Unallowable operation: psVector %s has incorrect type.", #NAME); \
     82    return(RVAL); \
     83}
    7384
    7485#define PS_VECTOR_CHECK_SIZE_EQUAL(VEC1, VEC2, RVAL) \
    7586if (VEC1->n != VEC2->n) { \
    76     psError(__func__,"Vector %s has size %d, Vector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \
     87    psError(__func__,"psVector %s has size %d, psVector %s has size %d.", #VEC1, VEC1->n, #VEC2, VEC2->n); \
    7788    return(RVAL); \
    7889}
     
    166177    PS_POLY macros:
    167178*****************************************************************************/
    168 #define PS_POLY_CHECK_NULL(NAME, NULL) \
     179#define PS_POLY_CHECK_NULL(NAME, RVAL) \
    169180if (NAME == NULL || NAME->coeff == NULL) { \
    170181    psError(__func__,"Unallowable operation: polynomial %s or its coeffs is NULL.", #NAME); \
    171     return(NULL); \
     182    return(RVAL); \
    172183} \
    173184
Note: See TracChangeset for help on using the changeset viewer.