[PATCH] Avoid PRIuMAX constant in domain events example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]