Skip to content

Commit 3ed0e36

Browse files
authored
Merge pull request #580 from pabuhler/format-check
add compile time check of format arguments to srtp_err_report()
2 parents 16ac91a + 921159e commit 3ed0e36

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

crypto/include/err.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@
4949
#include <stdarg.h>
5050
#include "srtp.h"
5151

52+
#if defined(__clang__) || (defined(__GNUC__) && defined(__has_attribute))
53+
#if __has_attribute(format)
54+
#define LIBSRTP_FORMAT_PRINTF(fmt, args) \
55+
__attribute__((format(__printf__, fmt, args)))
56+
#else
57+
#define LIBSRTP_FORMAT_PRINTF(fmt, args)
58+
#endif
59+
#else
60+
#define LIBSRTP_FORMAT_PRINTF(fmt, args)
61+
#endif
62+
5263
#ifdef __cplusplus
5364
extern "C" {
5465
#endif
@@ -96,7 +107,8 @@ srtp_err_status_t srtp_install_err_report_handler(
96107
*
97108
*/
98109

99-
void srtp_err_report(srtp_err_reporting_level_t level, const char *format, ...);
110+
void srtp_err_report(srtp_err_reporting_level_t level, const char *format, ...)
111+
LIBSRTP_FORMAT_PRINTF(2, 3);
100112

101113
/*
102114
* debug_module_t defines a debug module

0 commit comments

Comments
 (0)