[libvirt] [PATCHv2] fix failure when building with --disable-debug

Hu Tao hutao at cn.fujitsu.com
Wed Jul 11 10:40:05 UTC 2012


When building with --disable-debug, VIR_DEBUG expands to a nop.
But parameters to VIR_DEBUG can be variables that are passed only
to VIR_DEBUG. In the case the building system complains about unused
variables.
---
 cfg.mk             |    2 ++
 src/util/logging.h |    8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/cfg.mk b/cfg.mk
index 7664d5d..6e036fb 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -750,6 +750,8 @@ $(srcdir)/src/remote/remote_client_bodies.h: $(srcdir)/src/remote/remote_protoco
 	$(MAKE) -C src remote/remote_client_bodies.h
 
 # List all syntax-check exemptions:
+exclude_file_name_regexp--sc_avoid_attribute_unused_in_header = ^src/util/logging\.h$$
+
 exclude_file_name_regexp--sc_avoid_strcase = ^tools/virsh\.c$$
 
 _src1=libvirt|fdstream|qemu/qemu_monitor|util/(command|util)|xen/xend_internal|rpc/virnetsocket|lxc/lxc_controller
diff --git a/src/util/logging.h b/src/util/logging.h
index 70318d0..7cc5823 100644
--- a/src/util/logging.h
+++ b/src/util/logging.h
@@ -34,8 +34,14 @@
 #  define VIR_DEBUG_INT(category, f, l, ...)                            \
     virLogMessage(category, VIR_LOG_DEBUG, f, l, 0, __VA_ARGS__)
 # else
+/**
+ * virLogEatParam:
+ *
+ * Do nothing but eat parameters.
+ */
+static inline void virLogEatParam(void *unused ATTRIBUTE_UNUSED, ...) {}
 #  define VIR_DEBUG_INT(category, f, l, ...)    \
-    do { } while (0)
+    virLogEatParam((void*)category, f, l, __VA_ARGS__)
 # endif /* !ENABLE_DEBUG */
 
 # define VIR_INFO_INT(category, f, l, ...)                              \
-- 
1.7.10.2




More information about the libvir-list mailing list