testbot/TestLauncher: Tweak the ReportError() implementation.
Francois Gouget
fgouget at codeweavers.com
Mon Oct 15 08:38:14 CDT 2012
In particular make sure it behaves as if it was a single instruction, e.g. if used without a block after an 'if'.
Also make sure gcc will know to check the format string.
---
Apparently MinGW's compiler was already checking the OutputError()
parameters aginst its format string.
testbot/src/TestLauncher/TestLauncher.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/testbot/src/TestLauncher/TestLauncher.c b/testbot/src/TestLauncher/TestLauncher.c
index 855b773..a790470 100644
--- a/testbot/src/TestLauncher/TestLauncher.c
+++ b/testbot/src/TestLauncher/TestLauncher.c
@@ -26,17 +26,28 @@
#define strncpy_s(dest, size, src, max) strncpy((dest), (src), (max))
#define strcat_s(dest, size, src) strcat((dest), (src))
#endif
-
#define countof(Array) (sizeof(Array) / sizeof(Array[0]))
-#define ReportError LocationFile = __FILE__; LocationLine = __LINE__; OutputError
-static const char *LocationFile;
-static unsigned LocationLine;
static unsigned Failures = 0;
static unsigned Skips = 0;
static char TestName[_MAX_PATH];
-static void OutputError(const char *Format, ...)
+
+#define ReportError (_SetErrorLocation(__FILE__, __LINE__), 0) ? (void)0 : _ReportError
+
+static const char *LocationFile;
+static unsigned LocationLine;
+static void _SetErrorLocation(const char* file, int line)
+{
+ LocationFile = file;
+ LocationLine = line;
+}
+
+#ifdef __GNUC__
+static void _ReportError(const char *Format, ...) __attribute__((format (printf,1,2) ));
+#endif
+
+static void _ReportError(const char *Format, ...)
{
va_list ArgList;
--
1.7.10.4
More information about the wine-patches
mailing list