From b0786dce8b9ce2ed5216a491fc3cc8a1d4b6ebcf Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Thu, 12 Nov 2009 17:16:20 -0500 Subject: [PATCH] os4x: added BARRY_GCC_FORMAT_CHECK --- opensync-plugin-0.4x/src/Makefile.am | 1 + opensync-plugin-0.4x/src/format_check.h | 32 ++++++++++++++++++++++++++++++++ opensync-plugin-0.4x/src/trace.h | 3 ++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 opensync-plugin-0.4x/src/format_check.h diff --git a/opensync-plugin-0.4x/src/Makefile.am b/opensync-plugin-0.4x/src/Makefile.am index fd4299ea..ad94f9ff 100644 --- a/opensync-plugin-0.4x/src/Makefile.am +++ b/opensync-plugin-0.4x/src/Makefile.am @@ -34,6 +34,7 @@ barry_sync_la_SOURCES = \ vjournal.cc vjournal.h \ vtodo.cc vtodo.h \ vformat.c vformat.h \ + format_check.h \ trace.h \ tosserror.h diff --git a/opensync-plugin-0.4x/src/format_check.h b/opensync-plugin-0.4x/src/format_check.h new file mode 100644 index 00000000..c7b46210 --- /dev/null +++ b/opensync-plugin-0.4x/src/format_check.h @@ -0,0 +1,32 @@ +// +// \file format_check.h +// Simple macro to enable gcc printf-style format string checks +// + +/* + Copyright (C) 2009, Net Direct Inc. (http://www.netdirect.ca/) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License in the COPYING file at the + root directory of this project for more details. +*/ + +#ifndef __BARRY_SYNC_FORMAT_CHECK_H__ +#define __BARRY_SYNC_FORMAT_CHECK_H__ + +#if __GNUC__ +#define BARRY_GCC_FORMAT_CHECK(a,b) __attribute__ ((format(printf, a, b))) +#else +#define BARRY_GCC_FORMAT_CHECK(a,b) +#endif + +#endif + diff --git a/opensync-plugin-0.4x/src/trace.h b/opensync-plugin-0.4x/src/trace.h index a170181c..db5870be 100644 --- a/opensync-plugin-0.4x/src/trace.h +++ b/opensync-plugin-0.4x/src/trace.h @@ -25,6 +25,7 @@ #include #include #include +#include "format_check.h" class Trace { @@ -53,7 +54,7 @@ public: osync_trace(TRACE_INTERNAL, "barry_sync: %s", t); } - void logf(const char *t, ...) + void logf(const char *t, ...) BARRY_GCC_FORMAT_CHECK(2, 3) { va_list vl; va_start(vl, t); -- 2.11.4.GIT