IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 12, 2006, 11:42:05 AM (20 years ago)
Author:
jhoblitt
Message:

code sanitizing; variable names, types, & style

File:
1 edited

Legend:

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

    r8801 r8803  
    1111 *  @author Eric Van Alst, MHPCC
    1212 *
    13  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-09-12 21:25:59 $
     13 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-09-12 21:42:05 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    127127{
    128128    char errMsg[MAX_STRING_LENGTH];
    129     psErr* err;
    130129    char msgName[MAX_STRING_LENGTH];
    131130
    132     // XXX a VLA should be used here instead of a fixed size buffer
    133     snprintf(msgName, MAX_STRING_LENGTH, "%s (%s:%d)", func, filename, lineno);
    134 
     131    // if this the origin of a new error reset the error stack
    135132    if (new) {
    136133        psErrorClear();
    137134    }
    138135
    139     //XXX this could go away if we had a p_psTraceV() that accept file,
    140     //lieno, etc.  Get the variable list parameters to pass to logging function
    141     va_list argPtr;             // variable list arguement pointer
    142     va_start(argPtr, format);
    143     vsnprintf(errMsg, MAX_STRING_LENGTH, format, argPtr);
    144     va_end(argPtr);
    145 
    146     // Remove a single trailing \n from message -- it interferes with psErrorStackPrint
    147     int len = strlen(errMsg);
     136    snprintf(msgName, MAX_STRING_LENGTH, "%s (%s:%d)", func, filename, lineno);
     137
     138    va_list ap;
     139    va_start(ap, format);
     140
     141    vsnprintf(errMsg, MAX_STRING_LENGTH, format, ap);
     142
     143    va_end(ap);
     144
     145    // Remove a single trailing \n from message -- it interferes with
     146    // psErrorStackPrint
     147    size_t len = strlen(errMsg);
    148148    if (len > 0 && errMsg[len - 1] == '\n') {
    149149        errMsg[len - 1] = '\0';
    150         len--;
    151     }
    152 
    153     err = psErrAlloc(msgName,code,errMsg);
     150    }
     151
     152    psErr *err = psErrAlloc(msgName, code, errMsg);
    154153    psErrorStackPush(err);
    155154
     
    161160    #endif
    162161
    163 
    164162    psFree(err);
    165163
     
    170168                 int lineno,
    171169                 const char* func,
    172                  const char* fmt,
     170                 const char* format,
    173171                 ...)
    174172{
     
    177175    snprintf(msgName, MAX_STRING_LENGTH, "%s (%s:%d)", func, file, lineno);
    178176
    179     va_list argPtr;             // variable list argument pointer
    180 
    181     // Get the variable list parameters to pass to logging function
    182     va_start(argPtr, fmt);
    183 
    184     psLogMsgV(msgName, PS_LOG_WARN, fmt, argPtr);
    185 
    186     // Clean up stack after variable argument has been used
    187     va_end(argPtr);
     177    va_list ap;
     178    va_start(ap, format);
     179
     180    psLogMsgV(msgName, PS_LOG_WARN, format, ap);
     181
     182    va_end(ap);
    188183
    189184    return;
     
    204199        if (which < 0 || which >= psArrayLength(errorStack)) {
    205200            // no error at the given location
    206             result = psErrAlloc("",PS_ERR_NONE,"");
     201            result = psErrAlloc("", PS_ERR_NONE, "");
    207202        } else {
    208203            // a new reference passed back
     
    252247void psErrorStackPrint(FILE *fd, const char *format, ...)
    253248{
    254     va_list argPtr;             // variable list arguement pointer
    255 
    256     // Get the variable list parameters to pass to logging function
    257     va_start(argPtr, format);
    258 
    259     psErrorStackPrintV(fd,format,argPtr);
    260 
    261     va_end(argPtr);
     249    va_list ap;             // variable list arguement pointer
     250
     251    va_start(ap, format);
     252
     253    psErrorStackPrintV(fd, format, ap);
     254
     255    va_end(ap);
    262256}
    263257
Note: See TracChangeset for help on using the changeset viewer.