[pkg-opensc-commit] [opensc] 209/295: Add GCC format checking attributes to log functions
Eric Dorland
eric at moszumanska.debian.org
Sat Jun 24 21:11:32 UTC 2017
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository opensc.
commit 2e7519818174f5ac2eeae17779f66820ebd8aa38
Author: Maciej S. Szmigiero <mail at maciej.szmigiero.name>
Date: Thu Aug 25 00:12:55 2016 +0200
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 at maciej.szmigiero.name>
---
src/libopensc/log.h | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/libopensc/log.h b/src/libopensc/log.h
index 3517300..72370d8 100644
--- a/src/libopensc/log.h
+++ b/src/libopensc/log.h
@@ -52,11 +52,24 @@ enum {
#define sc_log _sc_log
#endif
-void sc_do_log(struct sc_context *ctx, int level, const char *file, int line, const char *func,
+#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
*
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/opensc.git
More information about the pkg-opensc-commit
mailing list