Changeset d16fc78 in mainline for kernel/generic/include/print.h


Ignore:
Timestamp:
2010-11-26T01:07:42Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
855e0d8
Parents:
1e27d85
Message:
  • verify the correctness of printf()'s and friends' attributes in compile time (use NVERIFY_PRINTF define to suppress the checks)
  • separate non-C99 compliant printf() checks to a standalone 'print5' test and u

se NVERIFY_PRINTF for it

  • improve 'print2' test (use portable constant macros and explicit types)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/print.h

    r1e27d85 rd16fc78  
    3939#include <stdarg.h>
    4040
     41#ifndef NVERIFY_PRINTF
     42
     43#define PRINTF_ATTRIBUTE(start, end) \
     44        __attribute__((format(gnu_printf, start, end)))
     45
     46#else /* NVERIFY_PRINTF */
     47
     48#define PRINTF_ATTRIBUTE(start, end)
     49
     50#endif /* NVERIFY_PRINTF */
     51
    4152#define EOF  (-1)
    4253
    4354extern int puts(const char *s);
    44 extern int printf(const char *fmt, ...);
    45 extern int snprintf(char *str, size_t size, const char *fmt, ...);
     55extern int printf(const char *fmt, ...)
     56    PRINTF_ATTRIBUTE(1, 2);
     57extern int snprintf(char *str, size_t size, const char *fmt, ...)
     58    PRINTF_ATTRIBUTE(3, 4);
    4659
    4760extern int vprintf(const char *fmt, va_list ap);
Note: See TracChangeset for help on using the changeset viewer.