IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 23, 2004, 12:02:06 PM (22 years ago)
Author:
evanalst
Message:

Add logic for invalid index to psErrorGet function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sysUtils/psError.c

    r1810 r1868  
    1010 *  @author Eric Van Alst, MHPCC
    1111 *   
    12  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-09-14 23:48:25 $
     12 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-09-23 22:02:06 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9595}
    9696
    97 void psErrorMsg(const char *name, psErrorCode code, bool new, const char* fmt, ...)
     97psErrorCode psErrorMsg(const char *name, psErrorCode code, bool new, const char* fmt, ...)
    9898{
    9999    char errMsg[1024];
    100100    psErr* err;
     101    char* msgName;
     102
     103    // Check for null pointer and if found set to empty string;
     104    if ( name == NULL ) {
     105        msgName = "";
     106    } else {
     107        msgName = (char*)name;
     108    }
    101109
    102110    va_list argPtr;             // variable list arguement pointer
     
    110118
    111119    vsnprintf(errMsg,1024,fmt,argPtr);
    112     err = psErrAlloc(name,code,errMsg);
     120    err = psErrAlloc(msgName,code,errMsg);
    113121    pushErrorStack(err);
    114122
    115123    // Call logging function with PS_LOG_ERROR level
    116     psLogMsg(name, PS_LOG_ERROR, errMsg);
     124    psLogMsg(msgName, PS_LOG_ERROR, errMsg);
    117125
    118126    // Clean up stack after variable argument has been used
     
    120128
    121129    psFree(err);
     130
     131    return code;
    122132}
    123133
     
    128138    pthread_mutex_lock(&lockErrorStack);
    129139
    130     which = errorStackSize-1-which;     // the which input is from the end of errorStack
    131     if (which < 0 || which >= errorStackSize) {
    132         result = psErrAlloc("",PS_ERR_NONE,"");    // no error at the given location
     140    // Check for negative reference and if found return PS_ERR_NONE
     141    if (which < 0 ) {
     142        result = psErrAlloc("", PS_ERR_NONE, "");
    133143    } else {
    134         result = psMemIncrRefCounter(errorStack[which]); // a new reference passed back
     144
     145        which = errorStackSize-1-which;     // the which input is from the end of errorStack
     146        if (which < 0 || which >= errorStackSize) {
     147            result = psErrAlloc("",PS_ERR_NONE,"");    // no error at the given location
     148        } else {
     149            result = psMemIncrRefCounter(errorStack[which]); // a new reference passed back
     150        }
    135151    }
    136152
Note: See TracChangeset for help on using the changeset viewer.