Index: trunk/psLib/src/sys/psTrace.c
===================================================================
--- trunk/psLib/src/sys/psTrace.c	(revision 8477)
+++ trunk/psLib/src/sys/psTrace.c	(revision 8575)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-08-22 23:52:40 $
+ *  @version $Revision: 1.75 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-08-24 23:52:00 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -518,31 +518,32 @@
     }
 
-    char clevel = 0;                    // letter-name for level
-    switch (level) {
-    case PS_LOG_ABORT:
-        clevel = 'A';
-        break;
-    case PS_LOG_ERROR:
-        clevel = 'E';
-        break;
-    case PS_LOG_WARN:
-        clevel = 'W';
-        break;
-    case PS_LOG_INFO:
-        clevel = 'I';
-        break;
-    default:
-        if (level >= 4) {
-            clevel = level + '0';
-        } else {
-            psTrace("psLib.sys", 2, "Invalid logMsg level: %d (%s)\n", level, format);
-            level = (level < 0) ? 0 : 9;
-            clevel = level + '0';
-        }
-    }
-
     // Only display this message if it's trace level is less than the level
     // of it's associatedcomponent.
     if (level <= psTraceGetLevel(comp)) {
+
+        char clevel = 0;                    // letter-name for level
+        switch (level) {
+        case PS_LOG_ABORT:
+            clevel = 'A';
+            break;
+        case PS_LOG_ERROR:
+            clevel = 'E';
+            break;
+        case PS_LOG_WARN:
+            clevel = 'W';
+            break;
+        case PS_LOG_INFO:
+            clevel = 'I';
+            break;
+        default:
+            if (level >= 4) {
+                clevel = level + '0';
+            } else {
+                psTrace("psLib.sys", 2, "Invalid logMsg level: %d (%s)\n", level, format);
+                level = (level < 0) ? 0 : 9;
+                clevel = level + '0';
+            }
+        }
+
         int maxLength = MAX_HEADER_LENGTH; // Maximum length of header string
         char head[maxLength + 2];       // the added two are for the ending | and \0
@@ -594,12 +595,5 @@
             // calculate the length of the formatted string
             // XXX this may or may not be a performance issue
-            #if 1
-            ssize_t traceLength = vsnprintf(NULL, 0, format, ap);
-            #else
-
-            ssize_t traceLength = MAX_TRACE_LENGTH;
-            #endif
-
-            char line[traceLength++];
+            char line[MAX_TRACE_LENGTH];
 
             // We indent each message one space for each level of the message.
@@ -607,5 +601,5 @@
                 write (traceFD, " ", 1);
             }
-            vsnprintf(line, traceLength, format, ap);
+            vsnprintf(&line[0], MAX_TRACE_LENGTH, format, ap);
             write (traceFD, line, strlen(line));
             if (line[strlen(line) - 1] != '\n') {
@@ -649,16 +643,17 @@
     PS_ASSERT_PTR_NON_NULL(format, );
 
+    va_list ap;
+    va_start(ap, format);
+
     // XXX file & lineo are currently unused
 
     // Append the function name to the facility
     size_t facilLength = strlen(facil); // Length of facility name
-    size_t funcLength = strlen(func);   // Length of function name
-    char fullFacil[facilLength + funcLength + 2]; // Full facility name is the facility + the function name
-    strcpy(&fullFacil[0], facil);
+    //size_t funcLength = strlen(func);   // Length of function name
+    char fullFacil[MAX_HEADER_LENGTH]; // Full facility name is the facility + the function name
+    strncpy(&fullFacil[0], facil, MAX_HEADER_LENGTH);
     fullFacil[facilLength] = '.';
-    strcpy(&fullFacil[facilLength + 1], func);
-
-    va_list ap;
-    va_start(ap, format);
+    strncpy(&fullFacil[facilLength + 1], func, MAX_HEADER_LENGTH - facilLength - 1);
+
     psTraceV(fullFacil, level, format, ap);
     va_end(ap);
