Fix format specifiers in test cases on Win32

Some of the test suites use fprintf with format specifiers
that are not supported on Win32 and are not fixed by gnulib.

The mingw32 compiler also has trouble detecting ssize_t
correctly, complaining that 'ssize_t' does not match
'signed size_t' (which it expects for %zd). Force the
cast to size_t to avoid this problem

* tests/testutils.c, tests/testutils.h: Fix printf
  annotation on virTestResult. Use virVasprintf
  instead of vfprintf
* tests/virhashtest.c: Use VIR_WARN instead of fprintf(stderr).
  Cast to size_t to avoid mingw32 compiler bug

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange
2012-04-04 14:33:27 +01:00
parent ea3bc548ac
commit f48de0f161
3 changed files with 23 additions and 12 deletions
+6 -2
View File
@@ -72,7 +72,7 @@ virtTestCountAverage(double *items, int nitems)
return (double) (sum / nitems);
}
ATTRIBUTE_FMT_PRINTF(3,4)
void virtTestResult(const char *name, int ret, const char *msg, ...)
{
va_list vargs;
@@ -89,7 +89,11 @@ void virtTestResult(const char *name, int ret, const char *msg, ...)
else {
fprintf(stderr, "FAILED\n");
if (msg) {
vfprintf(stderr, msg, vargs);
char *str;
if (virVasprintf(&str, msg, vargs) == 0) {
fprintf(stderr, "%s", str);
VIR_FREE(str);
}
}
}
} else {