diff options
author | Pavel Roskin <plroskin@gmail.com> | 2016-03-03 22:22:20 -0800 |
---|---|---|
committer | Pavel Roskin <plroskin@gmail.com> | 2016-03-03 22:56:09 -0800 |
commit | 9091c3eef25734ff77185cb997334abaf5487404 (patch) | |
tree | 0351677b5442d969444a7c4c33fcc3e2c12ddbb9 /common | |
parent | 4da6f8a538251d9e84c9571ab580758d027c99d4 (diff) | |
download | xrdp-proprietary-9091c3eef25734ff77185cb997334abaf5487404.tar.gz xrdp-proprietary-9091c3eef25734ff77185cb997334abaf5487404.zip |
Annotate printf-like functions if supported by the compiler
Both GCC and Clang support it. Add a macro from Autoconf archive to check
for format attribute support.
Diffstat (limited to 'common')
-rw-r--r-- | common/os_calls.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/common/os_calls.h b/common/os_calls.h index acfbe475..1bdb8a5b 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -41,17 +41,26 @@ #define g_tcp_select g_sck_select #define g_close_wait_obj g_delete_wait_obj +#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT) +#define printflike(arg_format, arg_first_check) \ + __attribute__((__format__(__printf__, arg_format, arg_first_check))) +#else +#define printflike(arg_format, arg_first_check) +#endif + int APP_CC g_rm_temp_dir(void); int APP_CC g_mk_temp_dir(const char* app_name); void APP_CC g_init(const char* app_name); void APP_CC g_deinit(void); void* APP_CC g_malloc(int size, int zero); void APP_CC g_free(void* ptr); -void DEFAULT_CC g_printf(const char *format, ...); -void DEFAULT_CC g_sprintf(char* dest, const char* format, ...); -void DEFAULT_CC g_snprintf(char* dest, int len, const char* format, ...); -void DEFAULT_CC g_writeln(const char* format, ...); -void DEFAULT_CC g_write(const char* format, ...); +void DEFAULT_CC g_printf(const char *format, ...) printflike(1, 2); +void DEFAULT_CC g_sprintf(char* dest, const char* format, ...) \ + printflike(2, 3); +void DEFAULT_CC g_snprintf(char* dest, int len, const char* format, ...) \ + printflike(3, 4); +void DEFAULT_CC g_writeln(const char* format, ...) printflike(1, 2); +void DEFAULT_CC g_write(const char* format, ...) printflike(1, 2); void APP_CC g_hexdump(char* p, int len); void APP_CC g_memset(void* ptr, int val, int size); void APP_CC g_memcpy(void* d_ptr, const void* s_ptr, int size); |