IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8575


Ignore:
Timestamp:
Aug 24, 2006, 1:52:00 PM (20 years ago)
Author:
Paul Price
Message:

Linux-64 doesn't seem to like variable length arrays. Reverting to fixed arrays.

File:
1 edited

Legend:

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

    r8477 r8575  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-08-22 23:52:40 $
     11 *  @version $Revision: 1.75 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-08-24 23:52:00 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    518518    }
    519519
    520     char clevel = 0;                    // letter-name for level
    521     switch (level) {
    522     case PS_LOG_ABORT:
    523         clevel = 'A';
    524         break;
    525     case PS_LOG_ERROR:
    526         clevel = 'E';
    527         break;
    528     case PS_LOG_WARN:
    529         clevel = 'W';
    530         break;
    531     case PS_LOG_INFO:
    532         clevel = 'I';
    533         break;
    534     default:
    535         if (level >= 4) {
    536             clevel = level + '0';
    537         } else {
    538             psTrace("psLib.sys", 2, "Invalid logMsg level: %d (%s)\n", level, format);
    539             level = (level < 0) ? 0 : 9;
    540             clevel = level + '0';
    541         }
    542     }
    543 
    544520    // Only display this message if it's trace level is less than the level
    545521    // of it's associatedcomponent.
    546522    if (level <= psTraceGetLevel(comp)) {
     523
     524        char clevel = 0;                    // letter-name for level
     525        switch (level) {
     526        case PS_LOG_ABORT:
     527            clevel = 'A';
     528            break;
     529        case PS_LOG_ERROR:
     530            clevel = 'E';
     531            break;
     532        case PS_LOG_WARN:
     533            clevel = 'W';
     534            break;
     535        case PS_LOG_INFO:
     536            clevel = 'I';
     537            break;
     538        default:
     539            if (level >= 4) {
     540                clevel = level + '0';
     541            } else {
     542                psTrace("psLib.sys", 2, "Invalid logMsg level: %d (%s)\n", level, format);
     543                level = (level < 0) ? 0 : 9;
     544                clevel = level + '0';
     545            }
     546        }
     547
    547548        int maxLength = MAX_HEADER_LENGTH; // Maximum length of header string
    548549        char head[maxLength + 2];       // the added two are for the ending | and \0
     
    594595            // calculate the length of the formatted string
    595596            // XXX this may or may not be a performance issue
    596             #if 1
    597             ssize_t traceLength = vsnprintf(NULL, 0, format, ap);
    598             #else
    599 
    600             ssize_t traceLength = MAX_TRACE_LENGTH;
    601             #endif
    602 
    603             char line[traceLength++];
     597            char line[MAX_TRACE_LENGTH];
    604598
    605599            // We indent each message one space for each level of the message.
     
    607601                write (traceFD, " ", 1);
    608602            }
    609             vsnprintf(line, traceLength, format, ap);
     603            vsnprintf(&line[0], MAX_TRACE_LENGTH, format, ap);
    610604            write (traceFD, line, strlen(line));
    611605            if (line[strlen(line) - 1] != '\n') {
     
    649643    PS_ASSERT_PTR_NON_NULL(format, );
    650644
     645    va_list ap;
     646    va_start(ap, format);
     647
    651648    // XXX file & lineo are currently unused
    652649
    653650    // Append the function name to the facility
    654651    size_t facilLength = strlen(facil); // Length of facility name
    655     size_t funcLength = strlen(func);   // Length of function name
    656     char fullFacil[facilLength + funcLength + 2]; // Full facility name is the facility + the function name
    657     strcpy(&fullFacil[0], facil);
     652    //size_t funcLength = strlen(func);   // Length of function name
     653    char fullFacil[MAX_HEADER_LENGTH]; // Full facility name is the facility + the function name
     654    strncpy(&fullFacil[0], facil, MAX_HEADER_LENGTH);
    658655    fullFacil[facilLength] = '.';
    659     strcpy(&fullFacil[facilLength + 1], func);
    660 
    661     va_list ap;
    662     va_start(ap, format);
     656    strncpy(&fullFacil[facilLength + 1], func, MAX_HEADER_LENGTH - facilLength - 1);
     657
    663658    psTraceV(fullFacil, level, format, ap);
    664659    va_end(ap);
Note: See TracChangeset for help on using the changeset viewer.