From a14161f01c078f6992d9d6b0b8e53616a8b4a638 Mon Sep 17 00:00:00 2001 From: Philipp Hahn Date: Mon, 27 Jul 2020 07:32:02 +0200 Subject: debug: Fix bit-rot in debug output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let the compiler optimize out the printf() call instead of doing it with the pre-processor as the later does not catch format string errors or the following case, where NULLSTR() is used but not defined: > libvirt-qemu-override.c: In function ‘libvirt_qemu_virConnectDomainQemuMonitorEventRegister’: > libvirt-qemu-override.c:271:34: warning: implicit declaration of function ‘NULLSTR’; did you mean ‘NULL’? [-Wimplicit-function-declaration] > 271 | pyobj_conn, pyobj_dom, NULLSTR(event), pyobj_cbData, flags); > | ^~~~~~~ > libvirt-qemu-override.c:39:28: note: in definition of macro ‘DEBUG’ > 39 | while (0) {printf(fmt, __VA_ARGS__);} > | ^~~~~~~~~~~ > libvirt-qemu-override.c:270:11: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Wformat=] > 270 | DEBUG("libvirt_qemu_virConnectDomainQemuMonitorEventRegister(%p %p %s %p %x) called\n", > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 271 | pyobj_conn, pyobj_dom, NULLSTR(event), pyobj_cbData, flags); > | ~~~~~~~~~~~~~~ > | | > | int > libvirt-qemu-override.c:39:23: note: in definition of macro ‘DEBUG’ > 39 | while (0) {printf(fmt, __VA_ARGS__);} > | ^~~ > libvirt-qemu-override.c:270:73: note: format string is defined here > 270 | DEBUG("libvirt_qemu_virConnectDomainQemuMonitorEventRegister(%p %p %s %p %x) called\n", > | ~^ > | | > | char * > | %d Copy the definition of NULLSTR from libvirt/src/internal.h to typewrappers.h Signed-off-by: Philipp Hahn --- libvirt-lxc-override.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libvirt-lxc-override.c') diff --git a/libvirt-lxc-override.c b/libvirt-lxc-override.c index 138ba5b..6f42902 100644 --- a/libvirt-lxc-override.c +++ b/libvirt-lxc-override.c @@ -36,7 +36,7 @@ extern PyObject *PyInit_cygvirtmod_lxc(void); printf(fmt, __VA_ARGS__) #else # define DEBUG(fmt, ...) \ - do {} while (0) + while (0) {printf(fmt, __VA_ARGS__);} #endif /************************************************************************ -- cgit v1.2.1