Changeset 8803 for trunk/psLib/src/sys/psError.c
- Timestamp:
- Sep 12, 2006, 11:42:05 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psError.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psError.c
r8801 r8803 11 11 * @author Eric Van Alst, MHPCC 12 12 * 13 * @version $Revision: 1.3 7$ $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 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 127 127 { 128 128 char errMsg[MAX_STRING_LENGTH]; 129 psErr* err;130 129 char msgName[MAX_STRING_LENGTH]; 131 130 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 135 132 if (new) { 136 133 psErrorClear(); 137 134 } 138 135 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); 148 148 if (len > 0 && errMsg[len - 1] == '\n') { 149 149 errMsg[len - 1] = '\0'; 150 len--; 151 } 152 153 err = psErrAlloc(msgName,code,errMsg); 150 } 151 152 psErr *err = psErrAlloc(msgName, code, errMsg); 154 153 psErrorStackPush(err); 155 154 … … 161 160 #endif 162 161 163 164 162 psFree(err); 165 163 … … 170 168 int lineno, 171 169 const char* func, 172 const char* f mt,170 const char* format, 173 171 ...) 174 172 { … … 177 175 snprintf(msgName, MAX_STRING_LENGTH, "%s (%s:%d)", func, file, lineno); 178 176 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); 188 183 189 184 return; … … 204 199 if (which < 0 || which >= psArrayLength(errorStack)) { 205 200 // no error at the given location 206 result = psErrAlloc("", PS_ERR_NONE,"");201 result = psErrAlloc("", PS_ERR_NONE, ""); 207 202 } else { 208 203 // a new reference passed back … … 252 247 void psErrorStackPrint(FILE *fd, const char *format, ...) 253 248 { 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); 262 256 } 263 257
Note:
See TracChangeset
for help on using the changeset viewer.
