From: "Daniel P. Berrange" <berrange(a)redhat.com>
The domain events example program uses asprintf() to avoid
portability problems with %llu in one place, but not in
another place. Make all places use asprintf() instead and
thus avoid need to use PRIuMAX
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
examples/domain-events/events-c/event-test.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/examples/domain-events/events-c/event-test.c
b/examples/domain-events/events-c/event-test.c
index 301caad..901d41d 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -271,8 +271,15 @@ static int myDomainEventBalloonChangeCallback(virConnectPtr conn
ATTRIBUTE_UNUSE
unsigned long long actual,
void *opaque ATTRIBUTE_UNUSED)
{
- printf("%s EVENT: Domain %s(%d) balloon change %" PRIuMAX
"KB\n",
- __func__, virDomainGetName(dom), virDomainGetID(dom), (uintmax_t)actual);
+ char *str = NULL;
+ /* HACK: use asprintf since we have gnulib's wrapper for %lld on Win32
+ * but don't have a printf() replacement with %lld */
+ if (asprintf(&str, "%s EVENT: Domain %s(%d) balloon change %lluKB\n",
+ __func__, virDomainGetName(dom), virDomainGetID(dom), actual) < 0)
+ return 0;
+
+ printf("%s", str);
+ free(str);
return 0;
}
--
1.8.2.1