aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLai Jiangshan <laijs@cn.fujitsu.com>2011-05-09 17:24:09 +0800
committerEric Blake <eblake@redhat.com>2011-05-11 12:41:14 -0600
commitb65f37a4a1feae6bc808d8ae8a8ff662bc146f66 (patch)
tree25fdc23c13c5015010c233979f944dc0444421fa /examples
parentmaint: avoid a couple of gnulib regressions (diff)
downloadlibvirt-b65f37a4a1feae6bc808d8ae8a8ff662bc146f66.tar.gz
libvirt-b65f37a4a1feae6bc808d8ae8a8ff662bc146f66.tar.bz2
libvirt-b65f37a4a1feae6bc808d8ae8a8ff662bc146f66.zip
libvirt,logging: cleanup VIR_XXX0()
These VIR_XXXX0 APIs make us confused, use the non-0-suffix APIs instead. How do these coversions works? The magic is using the gcc extension of ##. When __VA_ARGS__ is empty, "##" will swallow the "," in "fmt," to avoid compile error. example: origin after CPP high_level_api("%d", a_int) low_level_api("%d", a_int) high_level_api("a string") low_level_api("a string") About 400 conversions. 8 special conversions: VIR_XXXX0("") -> VIR_XXXX("msg") (avoid empty format) 2 conversions VIR_XXXX0(string_literal_with_%) -> VIR_XXXX(%->%%) 0 conversions VIR_XXXX0(non_string_literal) -> VIR_XXXX("%s", non_string_literal) (for security) 6 conversions Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/domain-events/events-c/event-test.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index 1f46d42a2..52ec5d01d 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -8,10 +8,8 @@
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
-#define VIR_DEBUG0(fmt) printf("%s:%d :: " fmt "\n", \
- __func__, __LINE__)
#define VIR_DEBUG(fmt, ...) printf("%s:%d: " fmt "\n", \
- __func__, __LINE__, __VA_ARGS__)
+ __func__, __LINE__, ##__VA_ARGS__)
#define STREQ(a,b) (strcmp(a,b) == 0)
#ifndef ATTRIBUTE_UNUSED
@@ -304,7 +302,7 @@ int main(int argc, char **argv)
sigaction(SIGTERM, &action_stop, NULL);
sigaction(SIGINT, &action_stop, NULL);
- VIR_DEBUG0("Registering domain event cbs");
+ VIR_DEBUG("Registering domain event cbs");
/* Add 2 callbacks to prove this works with more than just one */
callback1ret = virConnectDomainEventRegister(dconn, myDomainEventCallback1,
@@ -355,7 +353,7 @@ int main(int argc, char **argv)
}
}
- VIR_DEBUG0("Deregistering event handlers");
+ VIR_DEBUG("Deregistering event handlers");
virConnectDomainEventDeregister(dconn, myDomainEventCallback1);
virConnectDomainEventDeregisterAny(dconn, callback2ret);
virConnectDomainEventDeregisterAny(dconn, callback3ret);
@@ -365,7 +363,7 @@ int main(int argc, char **argv)
virConnectDomainEventDeregisterAny(dconn, callback7ret);
}
- VIR_DEBUG0("Closing connection");
+ VIR_DEBUG("Closing connection");
if (dconn && virConnectClose(dconn) < 0) {
printf("error closing\n");
}