• Guilherme Maciel Ferreira's avatar
    Increase LOG_LEVELS enum type safety · 3768362a
    Guilherme Maciel Ferreira authored
    Use enum LOG_LEVELS instead of int for log and trace levels.
    
    According to ISO/IEC 9899:2011, section 6.7.2.2
    (Enumeration specifiers), paragraph 4: "Each enumerated type
    shall be compatible with char, a signed integer type, or an
    unsigned integer type. The choice of type is implementation-
    defined, but shall be capable of representing the values of
    all the members". Section J.3.9 also exposes the implementation
    defined nature of enumeration signess.
    
    A negative value (-1) is assigned to objects of type enum
    LOG_LEVELS. However, the enumeration type might be implemented
    as unsigned integer, because there are only positive enumerators
    (enumeration members). Thus, this may cause signess mismatches on
    some architectures.
    Signed-off-by: 's avatarGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
    3768362a
StackTrace.c 5.24 KB