IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8627 for trunk/psLib/src/sys


Ignore:
Timestamp:
Aug 25, 2006, 6:34:28 PM (20 years ago)
Author:
jhoblitt
Message:

add gcc format attributes to:

psAbort()
psErrorStackPrint()
p_psError()
p_psWarning()
psLogMsg()
p_psTrace()

add PS_ASSERT_LONG_LARGER_THAN_OR_EQUAL
add PS_ASSERT_S64_WITHIN_RANGE
fix PS_ASSERT_LONG_WITHIN_RANGE
fix a wide range of format related issues:

  • missing format field specifiers
  • missing format args
  • incorrect format field specifiers
  • constants declared with the wrong type (float vs. int)
  • PS_ASSERT* for the wrong type
  • attemps to print structs with *printf()
  • unportable format specifiers, eg. long vs. long long
Location:
trunk/psLib/src/sys
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psAbort.h

    r4307 r8627  
    1212 *  @author Eric Van Alst, MHPCC
    1313 *
    14  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-06-17 23:39:51 $
     14 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-08-26 04:34:28 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    3737 *
    3838 */
     39#ifdef __GNUC__
     40void psAbort(
     41    const char *name,                  ///< Source of abort such as file or function detected
     42    const char *format,                   ///< A printf style formatting statement defining msg
     43    ...
     44) __attribute__((format(printf, 2, 3)));
     45#else // __GNUC__
    3946void psAbort(
    4047    const char *name,                  ///< Source of abort such as file or function detected
    … …  
    4249    ...
    4350);
     51#endif // __GNUC__
    4452
    4553/** @} */ // Doxygen - End of SystemGroup Functions
  • trunk/psLib/src/sys/psAssert.h

    r8409 r8627  
    33
    44#include <assert.h>
     5#include <inttypes.h>
     6
    57#include "psError.h"
    68#include "psLogMsg.h"
    … …  
    155157if ((NAME) < (LOWER) || (NAME) > (UPPER)) { \
    156158    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
    157             "Error: %s, %lld, is out of range.", \
     159            "Error: %s, %ld, is out of range.  Must be between %ld and %ld.", \
     160            #NAME, NAME, LOWER, UPPER); \
     161    return RVAL; \
     162}
     163
     164#define PS_ASSERT_LONG_LARGER_THAN_OR_EQUAL(NAME1, NAME2, RVAL) \
     165if (!((NAME1) >= (NAME2))) { \
     166    psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Error: !(%s >= %s) (%ld %ld).",\
     167            #NAME1, #NAME2, NAME1, NAME2); \
     168    return(RVAL); \
     169}
     170
     171#define PS_ASSERT_S64_WITHIN_RANGE(NAME, LOWER, UPPER, RVAL) \
     172if ((NAME) < (LOWER) || (NAME) > (UPPER)) { \
     173    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     174            "Error: %s, %" PRId64 ", is out of range.  Must be between %" PRId64 " and %" PRId64 ".", \
    158175            #NAME, NAME, LOWER, UPPER); \
    159176    return RVAL; \
  • trunk/psLib/src/sys/psConfigure.c

    r8232 r8627  
    1313 *  @author Robert DeSonia, MHPCC
    1414 *
    15  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2006-08-08 23:32:23 $
     15 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2006-08-26 04:34:28 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    8080    nCorrupted = psMemCheckCorruption(false);
    8181    if (nCorrupted > 0) {
    82         psError(PS_ERR_UNKNOWN, true, "%d memory blocks corrupted; list written to %s.\n", nCorrupted);
     82        psError(PS_ERR_UNKNOWN, true, "%d memory blocks corrupted; list written to %s.\n", nCorrupted, memCheckName);
    8383    } else {
    8484        psLogMsg(__func__, PS_LOG_INFO, "No memory corruption found.\n");
  • trunk/psLib/src/sys/psError.h

    r8231 r8627  
    1212 *  @author Eric Van Alst, MHPCC
    1313 *
    14  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-08-08 23:11:25 $
     14 *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-08-26 04:34:28 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    9292 *
    9393 */
     94#ifdef __GNUC__
    9495void psErrorStackPrint(
    9596    FILE* fd,                          ///< destination file descriptor
    96     const char* format,                   ///< printf-style format of header line
    97     ...                                ///< any parameters required in fmt
    98 );
     97    const char* format,                ///< printf-style format of header line
     98    ...                                ///< any parameters required in fmt
     99) __attribute__((format(printf, 2, 3)));
     100#else // __GNUC__
     101void psErrorStackPrint(
     102    FILE* fd,                          ///< destination file descriptor
     103    const char* format,                ///< printf-style format of header line
     104    ...                                ///< any parameters required in fmt
     105);
     106#endif // __GNUC__
     107
    99108
    100109#ifndef SWIG
    … …  
    155164 *  @return psErrorcode    the given error code
    156165 */
     166#ifdef __GNUC__
    157167psErrorCode p_psError(
    158168    const char* filename,              ///< file name
    … …  
    163173    const char* format,                ///< printf-style format of header line
    164174    ...                                ///< any parameters required in fmt
    165 );
     175) __attribute__((format(printf, 6, 7)));
     176#else // __GNUC__
     177psErrorCode p_psError(
     178    const char* filename,              ///< file name
     179    unsigned int lineno,               ///< line number in file
     180    const char* func,                  ///< function name
     181    psErrorCode code,                  ///< Error class code
     182    bool new,                          ///< true if error originates at this location
     183    const char* format,                ///< printf-style format of header line
     184    ...                                ///< any parameters required in fmt
     185);
     186#endif // __GNUC__
    166187
    167188/** Logs a warning message.
    … …  
    172193 *
    173194*/
     195#ifdef __GNUC__
    174196void p_psWarning(
    175197    const char* file,                  ///< file name
    176198    int lineno,                        ///< line number in file
    177199    const char* func,                  ///< function name
    178     const char* fmt,                   ///< printf-style format of header line
    179     ...                                ///< any parameters required in fmt
    180 );
     200    const char* format,                ///< printf-style format of header line
     201    ...                                ///< any parameters required in fmt
     202) __attribute__((format(printf, 4, 5)));
     203#else // __GNUC__
     204void p_psWarning(
     205    const char* file,                  ///< file name
     206    int lineno,                        ///< line number in file
     207    const char* func,                  ///< function name
     208    const char* format,                ///< printf-style format of header line
     209    ...                                ///< any parameters required in fmt
     210);
     211#endif // __GNUC__
    181212
    182213
  • trunk/psLib/src/sys/psLogMsg.h

    r7587 r8627  
    1111 *  @author GLG, MHPCC
    1212 *
    13  *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-06-16 23:01:10 $
     13 *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-08-26 04:34:28 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    9090 *
    9191 */
     92#ifdef __GNUC__
     93void psLogMsg(
     94    const char *name,                  ///< name of the log source
     95    int level,                         ///< severity level of this log message
     96    const char *format,                ///< printf-style format command
     97    ...
     98) __attribute__((format(printf, 3, 4)));
     99#else // __GNUC__
    92100void psLogMsg(
    93101    const char *name,                  ///< name of the log source
    … …  
    96104    ...
    97105);
     106#endif // __GNUC__
    98107
    99108#ifndef SWIG
  • trunk/psLib/src/sys/psMemory.c

    r8540 r8627  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.79 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2006-08-24 02:17:17 $
     10*  @version $Revision: 1.80 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2006-08-26 04:34:28 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    530530        ptr = memExhaustedCallback(size);
    531531        if (ptr == NULL) {
    532             psAbort(__func__, "Failed to reallocate %ld bytes at %s:%d", size, file, lineno);
     532            psAbort(__func__, "Failed to reallocate %zd bytes at %s:%d", size, file, lineno);
    533533        }
    534534    }
  • trunk/psLib/src/sys/psTrace.h

    r8404 r8627  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-08-17 01:39:03 $
     11 *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-08-26 04:34:28 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    … …  
    8989);
    9090
    91 #else
     91#else // DOXYGEN
     92#ifdef __GNUC__
    9293/// Send a trace message
    9394void p_psTrace(
    … …  
    99100    const char *format,                ///< printf-style format command
    100101    ...                                ///< trace message arguments
     102) __attribute__((format(printf, 6, 7)));
     103#else // __GNUC__
     104void p_psTrace(
     105    const char* file,                  ///< file name
     106    int lineno,                        ///< line number in file
     107    const char* func,                  ///< function name
     108    const char *facil,                 ///< facilty of interest
     109    psS32 level,                       ///< desired trace level
     110    const char *format,                ///< printf-style format command
     111    ...                                ///< trace message arguments
    101112);
    102 
     113#endif // __GNUC__
    103114#ifndef SWIG
    104115#define psTrace(facil, level, ...) p_psTrace(__FILE__,__LINE__,__func__,facil, level, __VA_ARGS__)
    … …  
    110121    va_list ap                         ///< varargs argument list
    111122);
    112 
    113123#endif /* SWIG */
    114 
    115124#endif /* DOXYGEN */
    116125
Note: See TracChangeset for help on using the changeset viewer.