Add GCC format checking attributes to log functions
GCC can check format and parameter correctness in printf()-like functions for us so let's add necessary attributes to our log functions to emit a warning where their way of being called is likely in need to be inspected for correctness. Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
This commit is contained in:
parent
1c40426421
commit
2e75198181
|
@ -52,11 +52,24 @@ enum {
|
|||
#define sc_log _sc_log
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
/* GCC can check format and param correctness for us */
|
||||
void sc_do_log(struct sc_context *ctx, int level, const char *file, int line,
|
||||
const char *func, const char *format, ...)
|
||||
__attribute__ ((format (printf, 6, 7)));
|
||||
void sc_do_log_noframe(sc_context_t *ctx, int level, const char *format,
|
||||
va_list args) __attribute__ ((format (printf, 3, 0)));
|
||||
void _sc_debug(struct sc_context *ctx, int level, const char *format, ...)
|
||||
__attribute__ ((format (printf, 3, 4)));
|
||||
void _sc_log(struct sc_context *ctx, const char *format, ...)
|
||||
__attribute__ ((format (printf, 2, 3)));
|
||||
#else
|
||||
void sc_do_log(struct sc_context *ctx, int level, const char *file, int line, const char *func,
|
||||
const char *format, ...);
|
||||
void sc_do_log_noframe(sc_context_t *ctx, int level, const char *format, va_list args);
|
||||
void _sc_debug(struct sc_context *ctx, int level, const char *format, ...);
|
||||
void _sc_log(struct sc_context *ctx, const char *format, ...);
|
||||
#endif
|
||||
/**
|
||||
* @brief Log binary data to a sc context
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue