Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanimir Agovic2017-11-15 15:47:22 -0500
committerEugene Tarassov2017-11-22 12:47:44 -0500
commitec1091e7611b2604b7e4779890d259fcc7c3e809 (patch)
tree483ab10c86718748a84bef1f74387ed9f36b34b9
parent935ac2fab08a015be58cb840e8b486f75a8f8179 (diff)
downloadorg.eclipse.tcf.agent-ec1091e7611b2604b7e4779890d259fcc7c3e809.tar.gz
org.eclipse.tcf.agent-ec1091e7611b2604b7e4779890d259fcc7c3e809.tar.xz
org.eclipse.tcf.agent-ec1091e7611b2604b7e4779890d259fcc7c3e809.zip
trace: catch erroneous usage of format string
Annotate print_trace to catch erroneous usage of format string. Warnings won't show up by default and can be enable by specifing -Wformat or -Wall Change-Id: Ibd528b615075599fc82c943459139e7afda378ce Signed-off-by: Sanimir Agovic <sanimir@subpath.org>
-rw-r--r--agent/tcf/framework/trace.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/agent/tcf/framework/trace.h b/agent/tcf/framework/trace.h
index 2d6ed620..60ebb0c6 100644
--- a/agent/tcf/framework/trace.h
+++ b/agent/tcf/framework/trace.h
@@ -48,11 +48,17 @@ extern int log_mode;
#if ENABLE_Trace
+#if defined(__GNUC__)
+# define ATTR_PRINTF(FORMAT, ARG) __attribute__ ((format (printf, (FORMAT), (ARG))))
+#else
+# define ATTR_PRINTF(FORMAT, ARG)
+#endif
+
/*
* Print a trace message into log file.
* Use macro 'trace' instead of calling this function directly.
*/
-extern int print_trace(int mode, const char * fmt, ...);
+extern int print_trace(int mode, const char * fmt, ...) ATTR_PRINTF(2, 3);
extern FILE * log_file;

Back to the top