IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 3, 2004, 3:05:00 PM (22 years ago)
Author:
desonia
Message:

changed the psError signature to match SDRS. Also made misc. cleanups as
I was combing the files.

Location:
trunk/psLib/src/sysUtils
Files:
8 edited

Legend:

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

    r2204 r2273  
    1010 *  @author Eric Van Alst, MHPCC
    1111 *   
    12  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-10-27 00:57:31 $
     12 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-11-04 01:05:00 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6767}
    6868
    69 void psError(const char *name, const char *fmt, ...)
     69psErrorCode p_psError(const char* file,
     70                      int lineno,
     71                      const char* func,
     72                      psErrorCode code,
     73                      psBool new,
     74                      const char* fmt,
     75                      ...)
    7076{
    71     va_list argPtr;             // variable list arguement pointer
     77    char errMsg[2048];
     78    psErr* err;
     79    char msgName[256];
    7280
    73     // Get the variable list parameters to pass to logging function
    74     va_start(argPtr, fmt);
    75 
    76     // Call logging function with PS_LOG_ERROR level
    77     psLogMsgV(name, PS_LOG_ERROR, fmt, argPtr);
    78 
    79     // Clean up stack after variable argument has been used
    80     va_end(argPtr);
    81 }
    82 
    83 void psErrorClear()
    84 {
    85     pthread_mutex_lock(&lockErrorStack);
    86     for (psS32 lcv=0;lcv<errorStackSize;lcv++) {
    87         p_psMemSetPersistent(errorStack[lcv]->msg,false);
    88         p_psMemSetPersistent(errorStack[lcv]->name,false);
    89         p_psMemSetPersistent(errorStack[lcv],false);
    90         psFree(errorStack[lcv]);
    91     }
    92     errorStackSize = 0;
    93     pthread_mutex_unlock(&lockErrorStack);
    94 }
    95 
    96 psErrorCode psErrorMsg(const char *name, psErrorCode code, psBool new, const char* fmt, ...)
    97 {
    98     char errMsg[1024];
    99     psErr* err;
    100     char* msgName;
    101 
    102     // Check for null pointer and if found set to empty string;
    103     if ( name == NULL ) {
    104         msgName = "";
    105     } else {
    106         msgName = (char*)name;
    107     }
     81    snprintf(msgName,256,"%s (%s:%d)",func,file,lineno);
    10882
    10983    va_list argPtr;             // variable list arguement pointer
     
    11690    va_start(argPtr, fmt);
    11791
    118     vsnprintf(errMsg,1024,fmt,argPtr);
     92    vsnprintf(errMsg,2048,fmt,argPtr);
    11993    err = psErrAlloc(msgName,code,errMsg);
    12094    pushErrorStack(err);
     
    160134}
    161135
     136void psErrorClear(void)
     137{
     138    pthread_mutex_lock(&lockErrorStack);
     139
     140    for (int lcv=0;lcv < errorStackSize; lcv++) {
     141        p_psMemSetPersistent(errorStack[lcv],false);
     142        p_psMemSetPersistent(errorStack[lcv]->msg,false);
     143        p_psMemSetPersistent(errorStack[lcv]->name,false);
     144        psFree(errorStack[lcv]);
     145    }
     146    errorStackSize = 0;
     147
     148    pthread_mutex_unlock(&lockErrorStack);
     149
     150}
    162151void psErrorStackPrint(FILE *fd, const char *fmt, ...)
    163152{
  • trunk/psLib/src/sysUtils/psError.h

    r2204 r2273  
    1212 *  @author Eric Van Alst, MHPCC
    1313 *
    14  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-10-27 00:57:31 $
     14 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-11-04 01:05:00 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    104104 *  log message.
    105105 *
     106 *  This function modifies the error stack.
     107 *
     108 *  @return psErrorCode    the given error code
    106109 */
    107 void psError(
    108     const char *name,                  ///< Source of error such as file or function detected
    109     const char *fmt,                   ///< A printf style formatting statement defining msg
     110psErrorCode p_psError(
     111    const char* file,
     112    int lineno,
     113    const char* func,
     114    psErrorCode code,                  ///< Error class code
     115    psBool new,                        ///< true if error originates at this location
     116    const char* fmt,
    110117    ...
    111118);
    112119
    113 /** Reports an error message to the logging facility
    114  *
    115  *  This function will invoke the psLogMsg function with a level of
    116  *  PS_LOG_ERROR and pass the parameters name and fmt to generate a proper
    117  *  log message.
    118  *
    119  */
    120 psErrorCode psErrorMsg(
    121     const char *name,                  ///< Name of error in the form aaa.bbb.ccc
    122     psErrorCode code,                  ///< Error class code
    123     psBool new,                          ///< true if error originates at this location
    124     const char* fmt,                   ///< printf style formatting statement defining error message
    125     ...
    126 );
     120#define psError(code,new,...) p_psError(__FILE__,__LINE__,__func__,code,new,__VA_ARGS__)
    127121
    128122/** Create a new psErr struct
  • trunk/psLib/src/sysUtils/psErrorCodes.c

    r2204 r2273  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-27 00:57:31 $
     9 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:05:00 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4646            {PS_ERR_BAD_PARAMETER_NULL,"parameter is null"},
    4747            {PS_ERR_BAD_PARAMETER_SIZE,"size of parameter's data is outside of acceptable range."},
    48             {PS_ERR_UNEXPECTED_NULL,"unexpected NULL foun"},
     48            {PS_ERR_UNEXPECTED_NULL,"unexpected NULL found"},
     49            {PS_ERR_OS_CALL_FAILED,"unexpected result from an OS standard library call"},
    4950            //~End
    5051            {PS_ERR_N_ERR_CLASSES,"error classes end marker"}
     
    132133
    133134    if (errors == NULL) {
    134         psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister",
    135                    PS_ERR_BAD_PARAMETER_NULL, true,
    136                    PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION);
     135        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     136                PS_ERRORTEXT_psErrorCode_NULL_ERRORDESCRIPTION);
    137137        return;
    138138    }
     
    152152                        err) ) {
    153153
    154             psErrorMsg(PS_ERRORNAME_DOMAIN "psErrorRegister",
    155                        PS_ERR_UNKNOWN, false,
    156                        PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED,
    157                        i);
     154            psError(PS_ERR_UNKNOWN, false,
     155                    PS_ERRORTEXT_psErrorCode_ERRORCODE_REGISTER_FAILED,
     156                    i);
    158157        }
    159158        p_psMemSetPersistent(dynamicErrorCodes->head,true);
  • trunk/psLib/src/sysUtils/psErrorCodes.h

    r2204 r2273  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-27 00:57:31 $
     9 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-04 01:05:00 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252    PS_ERR_BAD_PARAMETER_NULL,   ///< parameter is null
    5353    PS_ERR_BAD_PARAMETER_SIZE,   ///< size of parameter's data is outside of acceptable range.
    54     PS_ERR_UNEXPECTED_NULL,   ///< unexpected NULL foun
     54    PS_ERR_UNEXPECTED_NULL,   ///< unexpected NULL found
     55    PS_ERR_OS_CALL_FAILED,   ///< unexpected result from an OS standard library call
    5556    //~End
    5657    PS_ERR_N_ERR_CLASSES               ///< end marker - should not be used as a true error
  • trunk/psLib/src/sysUtils/psLogMsg.c

    r2204 r2273  
    1111 *  @author George Gusciora, MHPCC
    1212 *
    13  *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-10-27 00:57:31 $
     13 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-11-04 01:05:00 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    110110
    111111    if (sscanf(dest, "%4s:%256s", protocol, location) < 2) {
    112         psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,
    113                    PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,
    114                    dest);
     112        psError(PS_ERR_LOCATION_INVALID, true,
     113                PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED,
     114                dest);
    115115        return false;
    116116    }
     
    131131            return true;
    132132        }
    133         psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,
    134                    PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID,
    135                    location);
     133        psError(PS_ERR_LOCATION_INVALID, true,
     134                PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID,
     135                location);
    136136        return 1;
    137137    } else if (strcmp(protocol, "file") == 0) {
     
    139139
    140140        if (file == NULL) {
    141             psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_IO,
    142                        PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,
    143                        location);
     141            psError(PS_ERR_IO, true,
     142                    PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED,
     143                    location);
    144144            return false;
    145145        }
     
    151151    }
    152152
    153     psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetDestination", true, PS_ERR_LOCATION_INVALID,
    154                PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL,
    155                protocol);
     153    psError(PS_ERR_LOCATION_INVALID, true,
     154            PS_ERRORTEXT_psLogMsg_UNSUPPORTED_PROTOCOL,
     155            protocol);
    156156    return false;
    157157}
     
    215215            break;
    216216        default:
    217             psErrorMsg(PS_ERRORNAME_DOMAIN "psLogSetFormat", true, PS_ERR_BAD_PARAMETER_VALUE,
    218                        PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr);
     217            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     218                    PS_ERRORTEXT_psLogMsg_UNKNOWN_KEY, *ptr);
    219219            break;
    220220        }
  • trunk/psLib/src/sysUtils/psMemory.c

    r2210 r2273  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2004-10-27 19:35:59 $
     10*  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2004-11-04 01:05:00 $
    1212*
    1313*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    100100{
    101101    if (ptr->refCounter < 1) {
    102         psErrorMsg(PS_ERRORNAME_DOMAIN "memProblemCallbackDefault", false, PS_ERR_MEMORY_CORRUPTION,
    103                    PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
    104                    ptr->id, ptr->file, ptr->lineno, file, lineno);
     102        psError(PS_ERR_MEMORY_CORRUPTION, false,
     103                PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
     104                ptr->id, ptr->file, ptr->lineno, file, lineno);
    105105    }
    106106
     
    228228
    229229    if (m == NULL) {
    230         psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
    231                    PS_ERRORTEXT_psMemory_NULL_BLOCK);
     230        psError(PS_ERR_MEMORY_CORRUPTION, true,
     231                PS_ERRORTEXT_psMemory_NULL_BLOCK);
    232232        return 1;
    233233    }
     
    235235    if (m->refCounter == 0) {
    236236        // using an unreferenced block of memory, are you?
    237         psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
    238                    PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE,
    239                    m->id);
     237        psError(PS_ERR_MEMORY_CORRUPTION, true,
     238                PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE,
     239                m->id);
    240240        return 1;
    241241    }
    242242
    243243    if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
    244         psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
    245                    PS_ERRORTEXT_psMemory_UNDERFLOW,
    246                    m->id);
     244        psError(PS_ERR_MEMORY_CORRUPTION, true,
     245                PS_ERRORTEXT_psMemory_UNDERFLOW,
     246                m->id);
    247247        return 1;
    248248    }
    249249    if (*(psPtr *)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) {
    250         psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
    251                    PS_ERRORTEXT_psMemory_OVERFLOW,
    252                    m->id);
     250        psError(PS_ERR_MEMORY_CORRUPTION, true,
     251                PS_ERRORTEXT_psMemory_OVERFLOW,
     252                m->id);
    253253        return 1;
    254254    }
     
    431431        psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
    432432
    433         psErrorMsg(PS_ERRORNAME_DOMAIN "psFree",PS_ERR_MEMORY_DEREF_USAGE,true,
    434                    PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
    435                    ptr->id, ptr->file, ptr->lineno, file, lineno);
     433        psError(PS_ERR_MEMORY_DEREF_USAGE,true,
     434                PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
     435                ptr->id, ptr->file, ptr->lineno, file, lineno);
    436436
    437437        return;
  • trunk/psLib/src/sysUtils/psString.c

    r2204 r2273  
    99 *  @author Eric Van Alst, MHPCC
    1010 *
    11  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-27 00:57:31 $
     11 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-04 01:05:00 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3838    if (nChar < 0) {
    3939        // Log error message and return NULL
    40         psErrorMsg(PS_ERRORNAME_DOMAIN "psStringNCopy", PS_ERR_BAD_PARAMETER_VALUE, true,
    41                    PS_ERRORTEXT_psString_NCHAR_NEGATIVE,
    42                    nChar);
     40        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     41                PS_ERRORTEXT_psString_NCHAR_NEGATIVE,
     42                nChar);
    4343        return NULL;
    4444    }
  • trunk/psLib/src/sysUtils/psTrace.c

    r2221 r2273  
    99 *  @author George Gusciora, MHPCC
    1010 *
    11  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-27 23:31:44 $
     11 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-04 01:05:00 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    161161    // XXX: Verify that this is the correct behavior.
    162162    if (strcmp("", addNodeName) == 0) {
    163         psErrorMsg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_NULL,true,
    164                    PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT);
     163        psError(PS_ERR_BAD_PARAMETER_NULL,true,
     164                PS_ERRORTEXT_psTrace_ADD_NULL_COMPONENT);
    165165        return false;
    166166    }
     
    173173
    174174    if (addNodeName[0] != '.') {
    175         psErrorMsg(PS_ERRORNAME_DOMAIN "componentAdd",PS_ERR_BAD_PARAMETER_VALUE,true,
    176                    PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME,
    177                    addNodeName);
     175        psError(PS_ERR_BAD_PARAMETER_VALUE,true,
     176                PS_ERRORTEXT_psTrace_MALFORMED_COMPONENT_NAME,
     177                addNodeName);
    178178        return false;
    179179    }
     
    262262    // Add the new component to the component tree.
    263263    if ( !componentAdd(compName, level) ) {
    264         psErrorMsg(PS_ERRORNAME_DOMAIN "psTraceSetLevel",
    265                    PS_ERR_UNKNOWN,
    266                    false,
    267                    PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT,
    268                    level,
    269                    compName);
     264        psError(PS_ERR_UNKNOWN, false,
     265                PS_ERRORTEXT_psTrace_FAILED_TO_ADD_COMPONENT,
     266                level,
     267                compName);
    270268
    271269        if (comp[0] != '.') {
     
    482480
    483481    if (NULL == comp) {
    484         psErrorMsg(PS_ERRORNAME_DOMAIN "psTrace", PS_ERR_BAD_PARAMETER_NULL, true,
    485                    PS_ERRORTEXT_psTrace_NULL_TRACETREE,
    486                    __func__);
     482        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     483                PS_ERRORTEXT_psTrace_NULL_TRACETREE,
     484                __func__);
    487485        return;
    488486    }
Note: See TracChangeset for help on using the changeset viewer.