Francois Gouget : testbot/TestLauncher: Tweak the ReportError() implementation.

Alexandre Julliard julliard at winehq.org
Mon Oct 15 14:34:12 CDT 2012


Module: tools
Branch: master
Commit: cc474d01ad968763ba2a1821d77b8b23e7896186
URL:    http://source.winehq.org/git/tools.git/?a=commit;h=cc474d01ad968763ba2a1821d77b8b23e7896186

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Mon Oct 15 15:38:14 2012 +0200

testbot/TestLauncher: Tweak the ReportError() implementation.

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.

---

 testbot/src/TestLauncher/TestLauncher.c |   21 ++++++++++++++++-----
 1 files 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;
 




More information about the wine-cvs mailing list