* [Qemu-devel] [PATCH v2 01/16] x86: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 7:38 ` Andreas Färber
` (2 more replies)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 02/16] s390: " Marc Marí
` (14 subsequent siblings)
15 siblings, 3 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Peter Crosthwaite, open list:X86, open list:X86,
Stefan Hajnoczi, Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/i386/kvm/pci-assign.c | 9 ++++-----
hw/i386/multiboot.c | 6 ++++--
target-i386/kvm.c | 8 ++++----
xen-hvm.c | 12 ++++++------
xen-mapcache.c | 8 ++++----
5 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index e55421a..35757ae 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -51,14 +51,13 @@
//#define DEVICE_ASSIGNMENT_DEBUG
#ifdef DEVICE_ASSIGNMENT_DEBUG
-#define DEBUG(fmt, ...) \
- do { \
- fprintf(stderr, "%s: " fmt, __func__ , __VA_ARGS__); \
- } while (0)
+#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 1
#else
-#define DEBUG(fmt, ...)
+#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 0
#endif
+#define DEBUG(fmt, ...) QEMU_DPRINTF(DEVICE_ASSIGNMENT_DEBUG_ENABLED, "pci_assign", fmt, ## __VA_ARGS__)
+
typedef struct PCIRegion {
int type; /* Memory or port I/O */
int valid;
diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
index 985ca1e..cd215dc 100644
--- a/hw/i386/multiboot.c
+++ b/hw/i386/multiboot.c
@@ -33,11 +33,13 @@
//#define DEBUG_MULTIBOOT
#ifdef DEBUG_MULTIBOOT
-#define mb_debug(a...) fprintf(stderr, ## a)
+#define DEBUG_MULTIBOOT_ENABLED 1
#else
-#define mb_debug(a...)
+#define DEBUG_MULTIBOOT_ENABLED 0
#endif
+#define mb_debug(a...) QEMU_DPRINTF(DEBUG_MULTIBOOT_ENABLED, "i386 multiboot", a)
+
#define MULTIBOOT_STRUCT_ADDR 0x9000
#if MULTIBOOT_STRUCT_ADDR > 0xf0000
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 4389959..d6cd89c 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -37,13 +37,13 @@
//#define DEBUG_KVM
#ifdef DEBUG_KVM
-#define DPRINTF(fmt, ...) \
- do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_KVM_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_KVM_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_KVM_ENABLED, "i386 kvm", fmt, ## __VA_ARGS__)
+
#define MSR_KVM_WALL_CLOCK 0x11
#define MSR_KVM_SYSTEM_TIME 0x12
diff --git a/xen-hvm.c b/xen-hvm.c
index a64486c..ccce342 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -26,16 +26,16 @@
#include <xen/hvm/params.h>
#include <xen/hvm/e820.h>
-//#define DEBUG_XEN_HVM
+//#define DEBUG_XEN
-#ifdef DEBUG_XEN_HVM
-#define DPRINTF(fmt, ...) \
- do { fprintf(stderr, "xen: " fmt, ## __VA_ARGS__); } while (0)
+#ifdef DEBUG_XEN
+#define DEBUG_XEN_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_XEN_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_XEN_ENABLED, "xen", fmt, ## __VA_ARGS__)
+
static MemoryRegion ram_memory, ram_640k, ram_lo, ram_hi;
static MemoryRegion *framebuffer;
static bool xen_in_migration;
diff --git a/xen-mapcache.c b/xen-mapcache.c
index eda914a..a50bb80 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -26,13 +26,13 @@
//#define MAPCACHE_DEBUG
#ifdef MAPCACHE_DEBUG
-# define DPRINTF(fmt, ...) do { \
- fprintf(stderr, "xen_mapcache: " fmt, ## __VA_ARGS__); \
-} while (0)
+#define MAPCACHE_DEBUG_ENABLED 1
#else
-# define DPRINTF(fmt, ...) do { } while (0)
+#define MAPCACHE_DEBUG_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(MAPCACHE_DEBUG_ENABLED, "xen_mapcache", fmt, ## __VA_ARGS__)
+
#if defined(__i386__)
# define MCACHE_BUCKET_SHIFT 16
# define MCACHE_MAX_SIZE (1UL<<31) /* 2GB Cap */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 01/16] x86: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 01/16] x86: Convert conditional compilation of debug printfs to regular ifs Marc Marí
@ 2014-05-13 7:38 ` Andreas Färber
2014-05-13 15:15 ` Eric Blake
[not found] ` <53722E62.8000304@redhat.com>
2 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2014-05-13 7:38 UTC (permalink / raw)
To: Marc Marí, qemu-devel
Cc: Stefan Hajnoczi, Peter Crosthwaite, xen-devel, kvm
Am 13.05.2014 09:02, schrieb Marc Marí:
> Modify debug macros to have the same format through the codebase and use regular
> ifs instead of ifdef.
>
> As the debug printf is always put in code, some casting had to be added to avoid
> warnings treated as errors at compile time.
>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
> hw/i386/kvm/pci-assign.c | 9 ++++-----
> hw/i386/multiboot.c | 6 ++++--
> target-i386/kvm.c | 8 ++++----
> xen-hvm.c | 12 ++++++------
> xen-mapcache.c | 8 ++++----
> 5 files changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
> index e55421a..35757ae 100644
> --- a/hw/i386/kvm/pci-assign.c
> +++ b/hw/i386/kvm/pci-assign.c
> @@ -51,14 +51,13 @@
> //#define DEVICE_ASSIGNMENT_DEBUG
>
> #ifdef DEVICE_ASSIGNMENT_DEBUG
> -#define DEBUG(fmt, ...) \
> - do { \
> - fprintf(stderr, "%s: " fmt, __func__ , __VA_ARGS__); \
> - } while (0)
> +#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 1
> #else
> -#define DEBUG(fmt, ...)
> +#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 0
> #endif
>
> +#define DEBUG(fmt, ...) QEMU_DPRINTF(DEVICE_ASSIGNMENT_DEBUG_ENABLED, "pci_assign", fmt, ## __VA_ARGS__)
This is broken, QEMU_DPRINTF() is not defined yet. Looks like an
ordering issue with 16/16.
Regards,
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 01/16] x86: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 01/16] x86: Convert conditional compilation of debug printfs to regular ifs Marc Marí
2014-05-13 7:38 ` Andreas Färber
@ 2014-05-13 15:15 ` Eric Blake
[not found] ` <53722E62.8000304@redhat.com>
2 siblings, 0 replies; 32+ messages in thread
From: Eric Blake @ 2014-05-13 15:15 UTC (permalink / raw)
To: Marc Marí, qemu-devel
Cc: Stefan Hajnoczi, Peter Crosthwaite, xen-devel,
Andreas Färber, kvm
[-- Attachment #1: Type: text/plain, Size: 2324 bytes --]
On 05/13/2014 01:02 AM, Marc Marí wrote:
> Modify debug macros to have the same format through the codebase and use regular
> ifs instead of ifdef.
>
> As the debug printf is always put in code, some casting had to be added to avoid
> warnings treated as errors at compile time.
Umm, where in this patch did you add casting? Don't add bogus lines to
the commit message (I was assuming that it might be a case where the
code has type mismatches, and where something like PRId32 would be
better than adding a cast - but couldn't find where that was. Maybe
other patches in the series are affected?)
>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
> -#define DEBUG(fmt, ...) \
> - do { \
> - fprintf(stderr, "%s: " fmt, __func__ , __VA_ARGS__); \
> - } while (0)
The old code was line-wrapped to fit in 80 columns...
> +#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 1
> #else
> -#define DEBUG(fmt, ...)
> +#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 0
> #endif
>
> +#define DEBUG(fmt, ...) QEMU_DPRINTF(DEVICE_ASSIGNMENT_DEBUG_ENABLED, "pci_assign", fmt, ## __VA_ARGS__)
the new code should probably try to do similar:
#define DEBUG(fmt, ...) \
QEMU_DPRINTF(DEVICE_ASSIGNMENT_DEBUG_ENABLED, \
"pci_assign", fmt, ## __VA_ARGS__)
Although __VA_ARGS__ is required by C99, the use of ##__VA_ARGS__ is a
gcc extension; are you sure that all other supported compilers handle
it? (I guess that's just clang)
If you want something portable to C99, just use one fewer macro
argument, so that you are guaranteed that __VA_ARGS__ will be non-empty
(that is, subsume fmt into the ...):
#define DEBUG(...) \
QEMU_DPRINTF(DEVICE_ASSIGNMENT_DEBUG_ENABLED, \
"pci_assign", __VA_ARGS__)
>
> +#define mb_debug(a...) QEMU_DPRINTF(DEBUG_MULTIBOOT_ENABLED, "i386 multiboot", a)
Use of 'a...' as a named var-arg parameter is a gcc extension, not
portable to C99. Again, will this compile on non-gcc? Unnamed ...
coupled with __VA_ARGS__ is the only fully portable way to do var-args.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 32+ messages in thread
[parent not found: <53722E62.8000304@redhat.com>]
* Re: [Qemu-devel] [PATCH v2 01/16] x86: Convert conditional compilation of debug printfs to regular ifs
[not found] ` <53722E62.8000304@redhat.com>
@ 2014-05-15 9:56 ` Marc Marí
0 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-15 9:56 UTC (permalink / raw)
To: Eric Blake; +Cc: qemu-devel
El Tue, 13 May 2014 08:38:26 -0600
Eric Blake <eblake@redhat.com> escribió:
> Although __VA_ARGS__ is required by C99, the use of ##__VA_ARGS__ is a
> gcc extension; are you sure that all other supported compilers handle
> it? (I guess that's just clang)
>
> If you want something portable to C99, just use one fewer macro
> argument, so that you are guaranteed that __VA_ARGS__ will be
> non-empty (that is, subsume fmt into the ...):
>
> #define DEBUG(...) \
> QEMU_DPRINTF(DEVICE_ASSIGNMENT_DEBUG_ENABLED, \
> "pci_assign", __VA_ARGS__)
>
I found some problems to convert from ## __VA_ARGS__ to __VA_ARGS__ in
some parts, and as I asked in IRC, it was pointed that "our HACKING
document recommends the fmt, ## __VA_ARGS__ approach, and it obviously
works on all the compilers we care about". So I will leave this as it
is now.
Marc
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 02/16] s390: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 01/16] x86: Convert conditional compilation of debug printfs to regular ifs Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 9:04 ` Cornelia Huck
2014-05-13 14:45 ` Eric Blake
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 03/16] scsi: " Marc Marí
` (13 subsequent siblings)
15 siblings, 2 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber, open list:Overall
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/s390x/s390-virtio-bus.c | 8 ++++----
hw/s390x/s390-virtio.c | 8 ++++----
target-s390x/helper.c | 22 ++++++++++++++--------
target-s390x/kvm.c | 8 ++++----
4 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 9c71afa..c3a6302 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -38,13 +38,13 @@
/* #define DEBUG_S390 */
#ifdef DEBUG_S390
-#define DPRINTF(fmt, ...) \
- do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_S390_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_S390_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_S390_ENABLED, "s390 virtio bus", fmt, ## __VA_ARGS__)
+
#define VIRTIO_EXT_CODE 0x2603
static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index aef2003..133c320 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -42,13 +42,13 @@
//#define DEBUG_S390
#ifdef DEBUG_S390
-#define DPRINTF(fmt, ...) \
- do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_S390_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_S390_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_S390_ENABLED, "s390 virtio", fmt, ## __VA_ARGS__)
+
#define MAX_BLK_DEVS 10
#define ZIPL_FILENAME "s390-zipl.rom"
diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index 7c76fc1..c5bfa7e 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -30,19 +30,25 @@
//#define DEBUG_S390_STDOUT
#ifdef DEBUG_S390
-#ifdef DEBUG_S390_STDOUT
-#define DPRINTF(fmt, ...) \
- do { fprintf(stderr, fmt, ## __VA_ARGS__); \
- qemu_log(fmt, ##__VA_ARGS__); } while (0)
+#define DEBUG_S390_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { qemu_log(fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_S390_ENABLED 0
#endif
+
+#ifdef DEBUG_S390_STDOUT
+#define DEBUG_S390_STDOUT_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_S390_STDOUT_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) \
+ do { \
+ if(DEBUG_S390_ENABLED) { \
+ qemu_log(fmt, ##__VA_ARGS__); \
+ QEMU_DPRINTF(DEBUG_S390_STDOUT_ENABLED, "s390x helper", fmt, ## __VA_ARGS__); \
+ } \
+ } while (0)
+
#ifdef DEBUG_S390_PTE
#define PTE_DPRINTF DPRINTF
#else
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index b7b0edc..5aad3c9 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -41,13 +41,13 @@
/* #define DEBUG_KVM */
#ifdef DEBUG_KVM
-#define DPRINTF(fmt, ...) \
- do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_KVM_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_KVM_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_KVM_ENABLED, "s390 kvm", fmt, ## __VA_ARGS__)
+
#define IPA0_DIAG 0x8300
#define IPA0_SIGP 0xae00
#define IPA0_B2 0xb200
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 02/16] s390: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 02/16] s390: " Marc Marí
@ 2014-05-13 9:04 ` Cornelia Huck
2014-05-13 14:45 ` Eric Blake
1 sibling, 0 replies; 32+ messages in thread
From: Cornelia Huck @ 2014-05-13 9:04 UTC (permalink / raw)
To: Marc Marí
Cc: Stefan Hajnoczi, Peter Crosthwaite, qemu-devel, open list:Overall,
Andreas Färber
On Tue, 13 May 2014 09:02:38 +0200
Marc Marí <marc.mari.barcelo@gmail.com> wrote:
I'd replace the subject with
"s390: convert debug printfs to QEMU_DPRINTF"
which is more descriptive and has the additional virtue of being
shorter ;)
> Modify debug macros to have the same format through the codebase and use regular
> ifs instead of ifdef.
>
> As the debug printf is always put in code, some casting had to be added to avoid
> warnings treated as errors at compile time.
>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
> hw/s390x/s390-virtio-bus.c | 8 ++++----
> hw/s390x/s390-virtio.c | 8 ++++----
> target-s390x/helper.c | 22 ++++++++++++++--------
> target-s390x/kvm.c | 8 ++++----
> 4 files changed, 26 insertions(+), 20 deletions(-)
>
> diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
> index 9c71afa..c3a6302 100644
> --- a/hw/s390x/s390-virtio-bus.c
> +++ b/hw/s390x/s390-virtio-bus.c
> @@ -38,13 +38,13 @@
> /* #define DEBUG_S390 */
>
> #ifdef DEBUG_S390
> -#define DPRINTF(fmt, ...) \
> - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
> +#define DEBUG_S390_ENABLED 1
> #else
> -#define DPRINTF(fmt, ...) \
> - do { } while (0)
> +#define DEBUG_S390_ENABLED 0
> #endif
>
> +#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_S390_ENABLED, "s390 virtio bus", fmt, ## __VA_ARGS__)
I think this line is a bit too long.
> +
> #define VIRTIO_EXT_CODE 0x2603
>
> static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
> diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
> index aef2003..133c320 100644
> --- a/hw/s390x/s390-virtio.c
> +++ b/hw/s390x/s390-virtio.c
> @@ -42,13 +42,13 @@
> //#define DEBUG_S390
>
> #ifdef DEBUG_S390
> -#define DPRINTF(fmt, ...) \
> - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
> +#define DEBUG_S390_ENABLED 1
> #else
> -#define DPRINTF(fmt, ...) \
> - do { } while (0)
> +#define DEBUG_S390_ENABLED 0
> #endif
>
> +#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_S390_ENABLED, "s390 virtio", fmt, ## __VA_ARGS__)
dito
> +
> #define MAX_BLK_DEVS 10
> #define ZIPL_FILENAME "s390-zipl.rom"
>
> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
> index b7b0edc..5aad3c9 100644
> --- a/target-s390x/kvm.c
> +++ b/target-s390x/kvm.c
> @@ -41,13 +41,13 @@
> /* #define DEBUG_KVM */
>
> #ifdef DEBUG_KVM
> -#define DPRINTF(fmt, ...) \
> - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
> +#define DEBUG_KVM_ENABLED 1
> #else
> -#define DPRINTF(fmt, ...) \
> - do { } while (0)
> +#define DEBUG_KVM_ENABLED 0
> #endif
>
> +#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_KVM_ENABLED, "s390 kvm", fmt, ## __VA_ARGS__)
dito :)
> +
> #define IPA0_DIAG 0x8300
> #define IPA0_SIGP 0xae00
> #define IPA0_B2 0xb200
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 02/16] s390: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 02/16] s390: " Marc Marí
2014-05-13 9:04 ` Cornelia Huck
@ 2014-05-13 14:45 ` Eric Blake
1 sibling, 0 replies; 32+ messages in thread
From: Eric Blake @ 2014-05-13 14:45 UTC (permalink / raw)
To: Marc Marí, qemu-devel
Cc: Stefan Hajnoczi, Peter Crosthwaite, Andreas Färber, Overall
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
On 05/13/2014 01:02 AM, Marc Marí wrote:
> Modify debug macros to have the same format through the codebase and use regular
> ifs instead of ifdef.
>
> As the debug printf is always put in code, some casting had to be added to avoid
> warnings treated as errors at compile time.
Same comments as in 1/16: make the commit message accurate, wrap long
lines, and see if you can avoid using gcc extensions.
>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
> hw/s390x/s390-virtio-bus.c | 8 ++++----
> hw/s390x/s390-virtio.c | 8 ++++----
> target-s390x/helper.c | 22 ++++++++++++++--------
> target-s390x/kvm.c | 8 ++++----
> 4 files changed, 26 insertions(+), 20 deletions(-)
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 03/16] scsi: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 01/16] x86: Convert conditional compilation of debug printfs to regular ifs Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 02/16] s390: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 04/16] highbank: " Marc Marí
` (12 subsequent siblings)
15 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
open list:sPAPR, Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/scsi/lsi53c895a.c | 17 ++++++++---------
hw/scsi/scsi-generic.c | 12 +++++-------
hw/scsi/spapr_vscsi.c | 8 ++++----
3 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index cb30414..4c92198 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -24,16 +24,16 @@
//#define DEBUG_LSI_REG
#ifdef DEBUG_LSI
-#define DPRINTF(fmt, ...) \
-do { printf("lsi_scsi: " fmt , ## __VA_ARGS__); } while (0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
+#define DEBUG_LSI_ENABLED 1
#else
-#define DPRINTF(fmt, ...) do {} while(0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__);} while (0)
+#define DEBUG_LSI_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_LSI_ENABLED, "lsi_scsi", fmt, ## __VA_ARGS__)
+#define BADF(fmt, ...) \
+ QEMU_DPRINTF(1, "lsi_scsi error", fmt, ## __VA_ARGS__); \
+ do { if(DEBUG_LSI_ENABLED) { exit(1); } } while (0)
+
#define LSI_MAX_DEVS 7
#define LSI_SCNTL0_TRG 0x01
@@ -1261,12 +1261,11 @@ again:
uint8_t data8;
int reg;
int operator;
-#ifdef DEBUG_LSI
+
static const char *opcode_names[3] =
{"Write", "Read", "Read-Modify-Write"};
static const char *operator_names[8] =
{"MOV", "SHL", "OR", "XOR", "AND", "SHR", "ADD", "ADC"};
-#endif
reg = ((insn >> 16) & 0x7f) | (insn & 0x80);
data8 = (insn >> 8) & 0xff;
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 8d92e0d..bf1207f 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -21,14 +21,13 @@
//#define DEBUG_SCSI
#ifdef DEBUG_SCSI
-#define DPRINTF(fmt, ...) \
-do { printf("scsi-generic: " fmt , ## __VA_ARGS__); } while (0)
+#define DEBUG_SCSI_ENABLED 1
#else
-#define DPRINTF(fmt, ...) do {} while(0)
+#define DEBUG_SCSI_ENABLED 0
#endif
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "scsi-generic: " fmt , ## __VA_ARGS__); } while (0)
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_SCSI_ENABLED, "scsi-generic", fmt, ## __VA_ARGS__)
+#define BADF(fmt, ...) QEMU_DPRINTF(1, "scsi-generic", fmt, ## __VA_ARGS__)
#include <stdio.h>
#include <sys/types.h>
@@ -303,8 +302,7 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *cmd)
SCSIDevice *s = r->req.dev;
int ret;
- DPRINTF("Command: lun=%d tag=0x%x len %zd data=0x%02x", lun, tag,
- r->req.cmd.xfer, cmd[0]);
+ DPRINTF("Command: len %zd data=0x%02x", r->req.cmd.xfer, cmd[0]);
#ifdef DEBUG_SCSI
{
diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
index d4ada4f..c844bb0 100644
--- a/hw/scsi/spapr_vscsi.c
+++ b/hw/scsi/spapr_vscsi.c
@@ -45,13 +45,13 @@
/*#define DEBUG_VSCSI*/
#ifdef DEBUG_VSCSI
-#define DPRINTF(fmt, ...) \
- do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_VSCSI_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_VSCSI_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_VSCSI_ENABLED, "spapr_vscsi", fmt, ## __VA_ARGS__)
+
/*
* Virtual SCSI device
*/
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 04/16] highbank: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (2 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 03/16] scsi: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 10:06 ` Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 05/16] xilinx: " Marc Marí
` (11 subsequent siblings)
15 siblings, 1 reply; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/net/xgmac.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c
index 88349ac..734c2e5 100644
--- a/hw/net/xgmac.c
+++ b/hw/net/xgmac.c
@@ -30,14 +30,16 @@
#include "net/net.h"
#include "net/checksum.h"
+//#define DEBUG_XGMAC
+
#ifdef DEBUG_XGMAC
-#define DEBUGF_BRK(message, args...) do { \
- fprintf(stderr, (message), ## args); \
- } while (0)
+#define DEBUG_XGMAC_ENABLED 1
#else
-#define DEBUGF_BRK(message, args...) do { } while (0)
+#define DEBUG_XGMAC_ENABLED 0
#endif
+#define DEBUGF_BRK(message, args...) QEMU_DPRINTF(DEBUG_XGMAC_ENABLED, "xgmag", message, ## args)
+
#define XGMAC_CONTROL 0x00000000 /* MAC Configuration */
#define XGMAC_FRAME_FILTER 0x00000001 /* MAC Frame Filter */
#define XGMAC_FLOW_CTRL 0x00000006 /* MAC Flow Control */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 04/16] highbank: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 04/16] highbank: " Marc Marí
@ 2014-05-13 10:06 ` Marc Marí
0 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 10:06 UTC (permalink / raw)
To: Marc Marí
Cc: Stefan Hajnoczi, Peter Crosthwaite, qemu-devel,
Andreas Färber
El Tue, 13 May 2014 09:02:40 +0200
Marc Marí <marc.mari.barcelo@gmail.com> escribió:
> Modify debug macros to have the same format through the codebase and
> use regular ifs instead of ifdef.
>
> As the debug printf is always put in code, some casting had to be
> added to avoid warnings treated as errors at compile time.
>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
> hw/net/xgmac.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c
> index 88349ac..734c2e5 100644
> --- a/hw/net/xgmac.c
> +++ b/hw/net/xgmac.c
> @@ -30,14 +30,16 @@
> #include "net/net.h"
> #include "net/checksum.h"
>
> +//#define DEBUG_XGMAC
> +
> #ifdef DEBUG_XGMAC
> -#define DEBUGF_BRK(message, args...) do { \
> - fprintf(stderr, (message),
> ## args); \
> - } while (0)
> +#define DEBUG_XGMAC_ENABLED 1
> #else
> -#define DEBUGF_BRK(message, args...) do { } while (0)
> +#define DEBUG_XGMAC_ENABLED 0
> #endif
>
> +#define DEBUGF_BRK(message, args...)
> QEMU_DPRINTF(DEBUG_XGMAC_ENABLED, "xgmag", message, ## args) +
> #define XGMAC_CONTROL 0x00000000 /* MAC Configuration */
> #define XGMAC_FRAME_FILTER 0x00000001 /* MAC Frame Filter */
> #define XGMAC_FLOW_CTRL 0x00000006 /* MAC Flow Control */
In this file, the function name is already written when the macros are
called, so now it will appear two times. The calls to the macro can be
changed to not add the function name, which, in my opinion, is a bit
nicer.
Marc
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 05/16] xilinx: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (3 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 04/16] highbank: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 9:59 ` Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 06/16] spapr: " Marc Marí
` (10 subsequent siblings)
15 siblings, 1 reply; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/net/cadence_gem.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index cdb1825..aa93372 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -28,15 +28,16 @@
#include "net/net.h"
#include "net/checksum.h"
+//#define CADENCE_GEM_ERR_DEBUG
+
#ifdef CADENCE_GEM_ERR_DEBUG
-#define DB_PRINT(...) do { \
- fprintf(stderr, ": %s: ", __func__); \
- fprintf(stderr, ## __VA_ARGS__); \
- } while (0);
+#define CADENCE_GEM_ERR_DEBUG_ENABLED 1
#else
- #define DB_PRINT(...)
+#define CADENCE_GEM_ERR_DEBUG_ENABLED 0
#endif
+#define DB_PRINT(...) QEMU_DPRINTF(CADENCE_GEM_ERR_DEBUG_ENABLED, "cadence_gem", __VA_ARGS__)
+
#define GEM_NWCTRL (0x00000000/4) /* Network Control reg */
#define GEM_NWCFG (0x00000004/4) /* Network Config reg */
#define GEM_NWSTATUS (0x00000008/4) /* Network Status reg */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 05/16] xilinx: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 05/16] xilinx: " Marc Marí
@ 2014-05-13 9:59 ` Marc Marí
0 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 9:59 UTC (permalink / raw)
To: Marc Marí
Cc: Stefan Hajnoczi, Peter Crosthwaite, qemu-devel,
Andreas Färber
El Tue, 13 May 2014 09:02:41 +0200
Marc Marí <marc.mari.barcelo@gmail.com> escribió:
> Modify debug macros to have the same format through the codebase and
> use regular ifs instead of ifdef.
>
> As the debug printf is always put in code, some casting had to be
> added to avoid warnings treated as errors at compile time.
>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
> hw/net/cadence_gem.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> index cdb1825..aa93372 100644
> --- a/hw/net/cadence_gem.c
> +++ b/hw/net/cadence_gem.c
> @@ -28,15 +28,16 @@
> #include "net/net.h"
> #include "net/checksum.h"
>
> +//#define CADENCE_GEM_ERR_DEBUG
> +
> #ifdef CADENCE_GEM_ERR_DEBUG
> -#define DB_PRINT(...) do { \
> - fprintf(stderr, ": %s: ", __func__); \
> - fprintf(stderr, ## __VA_ARGS__); \
> - } while (0);
> +#define CADENCE_GEM_ERR_DEBUG_ENABLED 1
> #else
> - #define DB_PRINT(...)
> +#define CADENCE_GEM_ERR_DEBUG_ENABLED 0
> #endif
>
> +#define DB_PRINT(...) QEMU_DPRINTF(CADENCE_GEM_ERR_DEBUG_ENABLED,
> "cadence_gem", __VA_ARGS__) +
> #define GEM_NWCTRL (0x00000000/4) /* Network Control reg */
> #define GEM_NWCFG (0x00000004/4) /* Network Config reg */
> #define GEM_NWSTATUS (0x00000008/4) /* Network Status reg */
I saw that later in that file there are some DB_PRINT that do not add a
\n at the end (for example in L.1128). This can either be solved by
using fprintfs in between a #if CADENCE_GEM_ERR_DEBUG_ENABLED, adding a
\n after the message or leave the macro as it was.
Marc
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 06/16] spapr: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (4 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 05/16] xilinx: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 7:18 ` [Qemu-devel] [Qemu-ppc] " Alexander Graf
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 07/16] stellaris: " Marc Marí
` (9 subsequent siblings)
15 siblings, 1 reply; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
open list:sPAPR, Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/net/spapr_llan.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index c433337..1639f4b 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -39,11 +39,13 @@
/*#define DEBUG*/
#ifdef DEBUG
-#define DPRINTF(fmt...) do { fprintf(stderr, fmt); } while (0)
+#define DEBUG_ENABLED 1
#else
-#define DPRINTF(fmt...)
+#define DEBUG_ENABLED 0
#endif
+#define DPRINTF(fmt...) QEMU_DPRINTF(DEBUG_ENABLED, "spapr_llan", fmt)
+
/*
* Virtual LAN device
*/
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 06/16] spapr: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 06/16] spapr: " Marc Marí
@ 2014-05-13 7:18 ` Alexander Graf
0 siblings, 0 replies; 32+ messages in thread
From: Alexander Graf @ 2014-05-13 7:18 UTC (permalink / raw)
To: Marc Marí, qemu-devel
Cc: Stefan Hajnoczi, Peter Crosthwaite, sPAPR, Andreas Färber
On 13.05.14 09:02, Marc Marí wrote:
> Modify debug macros to have the same format through the codebase and use regular
> ifs instead of ifdef.
>
> As the debug printf is always put in code, some casting had to be added to avoid
> warnings treated as errors at compile time.
>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
I think this patch set should go in as a whole via a single tree.
Acked-by: Alexander Graf <agraf@suse.de>
Alex
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 07/16] stellaris: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (5 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 06/16] spapr: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 15:05 ` Eric Blake
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 08/16] tpm: " Marc Marí
` (8 subsequent siblings)
15 siblings, 1 reply; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/net/stellaris_enet.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
index d04e6a4..f6737a9 100644
--- a/hw/net/stellaris_enet.c
+++ b/hw/net/stellaris_enet.c
@@ -13,16 +13,17 @@
//#define DEBUG_STELLARIS_ENET 1
#ifdef DEBUG_STELLARIS_ENET
-#define DPRINTF(fmt, ...) \
-do { printf("stellaris_enet: " fmt , ## __VA_ARGS__); } while (0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "stellaris_enet: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
+#define DEBUG_STELLARIS_ENET_ENABLED 1
#else
-#define DPRINTF(fmt, ...) do {} while(0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "stellaris_enet: error: " fmt , ## __VA_ARGS__);} while (0)
+#define DEBUG_STELLARIS_ENET_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_STELLARIS_ENET_ENABLED, "stellaris_enet", fmt, ## __VA_ARGS__)
+
+#define BADF(fmt, ...) \
+ QEMU_DPRINTF(1, "stellaris_enet error", fmt, ## __VA_ARGS__); \
+ do { if (DEBUG_STELLARIS_ENET_ENABLED) { exit(1); } } while (0)
+
#define SE_INT_RX 0x01
#define SE_INT_TXER 0x02
#define SE_INT_TXEMP 0x04
@@ -97,7 +98,7 @@ static ssize_t stellaris_enet_receive(NetClientState *nc, const uint8_t *buf, si
return -1;
}
- DPRINTF("Received packet len=%d\n", size);
+ DPRINTF("Received packet len=%d\n", (int)size);
n = s->next_packet + s->np;
if (n >= 31)
n -= 31;
@@ -212,14 +213,14 @@ static void stellaris_enet_write(void *opaque, hwaddr offset,
switch (offset) {
case 0x00: /* IACK */
s->ris &= ~value;
- DPRINTF("IRQ ack %02x/%02x\n", value, s->ris);
+ DPRINTF("IRQ ack %02x/%02x\n", (unsigned)value, s->ris);
stellaris_enet_update(s);
/* Clearing TXER also resets the TX fifo. */
if (value & SE_INT_TXER)
s->tx_frame_len = -1;
break;
case 0x04: /* IM */
- DPRINTF("IRQ mask %02x/%02x\n", value, s->ris);
+ DPRINTF("IRQ mask %02x/%02x\n", (unsigned)value, s->ris);
s->im = value;
stellaris_enet_update(s);
break;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 07/16] stellaris: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 07/16] stellaris: " Marc Marí
@ 2014-05-13 15:05 ` Eric Blake
0 siblings, 0 replies; 32+ messages in thread
From: Eric Blake @ 2014-05-13 15:05 UTC (permalink / raw)
To: Marc Marí, qemu-devel
Cc: Stefan Hajnoczi, Peter Crosthwaite, Andreas Färber
[-- Attachment #1: Type: text/plain, Size: 3852 bytes --]
On 05/13/2014 01:02 AM, Marc Marí wrote:
> Modify debug macros to have the same format through the codebase and use regular
> ifs instead of ifdef.
>
> As the debug printf is always put in code, some casting had to be added to avoid
> warnings treated as errors at compile time.
Same comments as in 1/16 about long lines and gcc extensions (probably
for the entire series). Additionally...
>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
> hw/net/stellaris_enet.c | 21 +++++++++++----------
> 1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
> index d04e6a4..f6737a9 100644
> --- a/hw/net/stellaris_enet.c
> +++ b/hw/net/stellaris_enet.c
> @@ -13,16 +13,17 @@
> //#define DEBUG_STELLARIS_ENET 1
>
> #ifdef DEBUG_STELLARIS_ENET
> -#define DPRINTF(fmt, ...) \
> -do { printf("stellaris_enet: " fmt , ## __VA_ARGS__); } while (0)
In this case, the old code was also relying on the gcc extension. But
pre-patch, the gcc extension was only encountered if
DEBUG_StELLARIS_ENET was set (probably only by a developer using gcc for
temporary debugging), while post-patch the gcc extension is ALWAYS
encountered, regardless of developer.
> -#define BADF(fmt, ...) \
> -do { fprintf(stderr, "stellaris_enet: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
In the old code, BADF() could be used in a single statement context,
such as:
if (foo)
BADF("blah")
else
something();
(of course, that violates our coding style, but hear me out).
> +#define DEBUG_STELLARIS_ENET_ENABLED 1
> #else
> -#define DPRINTF(fmt, ...) do {} while(0)
> -#define BADF(fmt, ...) \
> -do { fprintf(stderr, "stellaris_enet: error: " fmt , ## __VA_ARGS__);} while (0)
> +#define DEBUG_STELLARIS_ENET_ENABLED 0
> #endif
>
> +#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_STELLARIS_ENET_ENABLED, "stellaris_enet", fmt, ## __VA_ARGS__)
> +
> +#define BADF(fmt, ...) \
> + QEMU_DPRINTF(1, "stellaris_enet error", fmt, ## __VA_ARGS__); \
> + do { if (DEBUG_STELLARIS_ENET_ENABLED) { exit(1); } } while (0)
However, in the new code, BADF() is no longer a single statement. You
either need to move the "do {" to appear before the QEMU_PRINTF
[preferred], or you can just declare that this is no longer a
single-statement macro at which point you could just drop the do/while
altogether [depends on our coding standard for safety]. The example
above, even though it violates coding standards, should demonstrate why
your change is wrong - the bare "else" is now a syntax error.
>
> - DPRINTF("Received packet len=%d\n", size);
> + DPRINTF("Received packet len=%d\n", (int)size);
Ah, we FINALLY get to an added cast. What you SHOULD be doing is using
len=%zu coupled with un-casted size, rather than papering over the type
mismatch.
> n = s->next_packet + s->np;
> if (n >= 31)
> n -= 31;
> @@ -212,14 +213,14 @@ static void stellaris_enet_write(void *opaque, hwaddr offset,
> switch (offset) {
> case 0x00: /* IACK */
> s->ris &= ~value;
> - DPRINTF("IRQ ack %02x/%02x\n", value, s->ris);
> + DPRINTF("IRQ ack %02x/%02x\n", (unsigned)value, s->ris);
> stellaris_enet_update(s);
> /* Clearing TXER also resets the TX fifo. */
> if (value & SE_INT_TXER)
> s->tx_frame_len = -1;
> break;
> case 0x04: /* IM */
> - DPRINTF("IRQ mask %02x/%02x\n", value, s->ris);
> + DPRINTF("IRQ mask %02x/%02x\n", (unsigned)value, s->ris);
More cases where you should be fixing the % format to use the correct
type, rather than adding a cast.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 08/16] tpm: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (6 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 07/16] stellaris: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 9:39 ` Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 09/16] i82374: " Marc Marí
` (7 subsequent siblings)
15 siblings, 1 reply; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/tpm/tpm_passthrough.c | 8 ++++----
hw/tpm/tpm_tis.c | 10 +++++-----
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index 56e9e0f..673ab0e 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -37,13 +37,13 @@
/* #define DEBUG_TPM */
#ifdef DEBUG_TPM
-#define DPRINTF(fmt, ...) \
- do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_TPM_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_TPM_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_TPM_ENABLED, "tpm-passthrough", fmt, ## __VA_ARGS__)
+
#define TYPE_TPM_PASSTHROUGH "tpm-passthrough"
#define TPM_PASSTHROUGH(obj) \
OBJECT_CHECK(TPMPassthruState, (obj), TYPE_TPM_PASSTHROUGH)
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 6f0a4d2..302f2bf 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -30,16 +30,16 @@
#include "qemu-common.h"
#include "qemu/main-loop.h"
-/*#define DEBUG_TIS */
+/*#define DEBUG_TIS*/
#ifdef DEBUG_TIS
-#define DPRINTF(fmt, ...) \
- do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_TIS_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_TIS_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_TIS_ENABLED, "tpm-tis", fmt, ## __VA_ARGS__)
+
/* whether the STS interrupt is supported */
#define RAISE_STS_IRQ
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 08/16] tpm: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 08/16] tpm: " Marc Marí
@ 2014-05-13 9:39 ` Marc Marí
0 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 9:39 UTC (permalink / raw)
To: Marc Marí
Cc: Stefan Hajnoczi, Peter Crosthwaite, qemu-devel,
Andreas Färber
El Tue, 13 May 2014 09:02:44 +0200
Marc Marí <marc.mari.barcelo@gmail.com> escribió:
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index 6f0a4d2..302f2bf 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -30,16 +30,16 @@
> #include "qemu-common.h"
> #include "qemu/main-loop.h"
>
> -/*#define DEBUG_TIS */
> +/*#define DEBUG_TIS*/
>
> #ifdef DEBUG_TIS
> -#define DPRINTF(fmt, ...) \
> - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
> +#define DEBUG_TIS_ENABLED 1
> #else
> -#define DPRINTF(fmt, ...) \
> - do { } while (0)
> +#define DEBUG_TIS_ENABLED 0
> #endif
>
> +#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_TIS_ENABLED, "tpm-tis",
> fmt, ## __VA_ARGS__) +
> /* whether the STS interrupt is supported */
> #define RAISE_STS_IRQ
>
I saw that later in that file there are some DPRINTF that do not add a
\n at the end (for example in L.141). As this codes are already in a
#ifdef DEBUG_TIS, some of this DPRINTFs can be changed to fprintf in
next versions.
Marc
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 09/16] i82374: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (7 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 08/16] tpm: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 9:20 ` Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 10/16] i8257: " Marc Marí
` (6 subsequent siblings)
15 siblings, 1 reply; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/dma/i82374.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/hw/dma/i82374.c b/hw/dma/i82374.c
index b8ad2e6..7026f24 100644
--- a/hw/dma/i82374.c
+++ b/hw/dma/i82374.c
@@ -27,14 +27,13 @@
//#define DEBUG_I82374
#ifdef DEBUG_I82374
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, "i82374: " fmt , ## __VA_ARGS__); } while (0)
+#define DEBUG_I82374_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
-do {} while (0)
+#define DEBUG_I82374_ENABLED 0
#endif
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "i82374 ERROR: " fmt , ## __VA_ARGS__); } while (0)
+
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_I82374_ENABLED, "i82374", fmt, ## __VA_ARGS__)
+#define BADF(fmt, ...) QEMU_DPRINTF(1, "i82374 ERROR", fmt, ## __VA_ARGS__)
typedef struct I82374State {
uint8_t commands[8];
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 09/16] i82374: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 09/16] i82374: " Marc Marí
@ 2014-05-13 9:20 ` Marc Marí
0 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 9:20 UTC (permalink / raw)
To: Marc Marí
Cc: Stefan Hajnoczi, Peter Crosthwaite, qemu-devel,
Andreas Färber
El Tue, 13 May 2014 09:02:45 +0200
Marc Marí <marc.mari.barcelo@gmail.com> escribió:
> hw/dma/i82374.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/hw/dma/i82374.c b/hw/dma/i82374.c
> index b8ad2e6..7026f24 100644
> --- a/hw/dma/i82374.c
> +++ b/hw/dma/i82374.c
> @@ -27,14 +27,13 @@
> //#define DEBUG_I82374
>
> #ifdef DEBUG_I82374
> -#define DPRINTF(fmt, ...) \
> -do { fprintf(stderr, "i82374: " fmt , ## __VA_ARGS__); } while (0)
> +#define DEBUG_I82374_ENABLED 1
> #else
> -#define DPRINTF(fmt, ...) \
> -do {} while (0)
> +#define DEBUG_I82374_ENABLED 0
> #endif
> -#define BADF(fmt, ...) \
> -do { fprintf(stderr, "i82374 ERROR: " fmt , ## __VA_ARGS__); } while
> (0) +
> +#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_I82374_ENABLED,
> "i82374", fmt, ## __VA_ARGS__) +#define BADF(fmt, ...)
> QEMU_DPRINTF(1, "i82374 ERROR", fmt, ## __VA_ARGS__)
> typedef struct I82374State {
> uint8_t commands[8];
In this file, the function name is already written when the macros are
called, so now it will appear two times. The calls to the macro can be
changed to not add the function name, which, in my opinion, is a bit
nicer.
Marc
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 10/16] i8257: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (8 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 09/16] i82374: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 11/16] rc4030: " Marc Marí
` (5 subsequent siblings)
15 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/dma/i8257.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c
index 4490372..22cb2bf 100644
--- a/hw/dma/i8257.c
+++ b/hw/dma/i8257.c
@@ -27,15 +27,16 @@
/* #define DEBUG_DMA */
-#define dolog(...) fprintf (stderr, "dma: " __VA_ARGS__)
#ifdef DEBUG_DMA
-#define linfo(...) fprintf (stderr, "dma: " __VA_ARGS__)
-#define ldebug(...) fprintf (stderr, "dma: " __VA_ARGS__)
+#define DEBUG_DMA_ENABLED 1
#else
-#define linfo(...)
-#define ldebug(...)
+#define DEBUG_DMA_ENABLED 0
#endif
+#define dolog(...) QEMU_DPRINTF(1, "dma", __VA_ARGS__)
+#define linfo(...) QEMU_DPRINTF(DEBUG_DMA_ENABLED, "dma", __VA_ARGS__);
+#define ldebug linfo
+
struct dma_regs {
int now[2];
uint16_t base[2];
@@ -301,7 +302,7 @@ static uint64_t read_cont(void *opaque, hwaddr nport, unsigned size)
break;
}
- ldebug ("read_cont: nport %#06x, iport %#04x val %#x\n", nport, iport, val);
+ ldebug ("read_cont: nport %#06x, iport %#04x val %#x\n", (unsigned)nport, iport, val);
return val;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 11/16] rc4030: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (9 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 10/16] i8257: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 9:16 ` Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 12/16] sd: " Marc Marí
` (4 subsequent siblings)
15 siblings, 1 reply; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/dma/rc4030.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/hw/dma/rc4030.c b/hw/dma/rc4030.c
index af26632..84f9f33 100644
--- a/hw/dma/rc4030.c
+++ b/hw/dma/rc4030.c
@@ -32,17 +32,16 @@
//#define DEBUG_RC4030
//#define DEBUG_RC4030_DMA
-#ifdef DEBUG_RC4030
-#define DPRINTF(fmt, ...) \
-do { printf("rc4030: " fmt , ## __VA_ARGS__); } while (0)
static const char* irq_names[] = { "parallel", "floppy", "sound", "video",
"network", "scsi", "keyboard", "mouse", "serial0", "serial1" };
+#ifdef DEBUG_RC4030
+#define DEBUG_RC4030_ENABLED 1
#else
-#define DPRINTF(fmt, ...)
+#define DEBUG_RC4030_ENABLED 0
#endif
-#define RC4030_ERROR(fmt, ...) \
-do { fprintf(stderr, "rc4030 ERROR: %s: " fmt, __func__ , ## __VA_ARGS__); } while (0)
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_RC4030_ENABLED, "rc4030", fmt, ## __VA_ARGS__)
+#define RC4030_ERROR(fmt, ...) QEMU_DPRINTF(1, "rc4030 ERROR", fmt, ## __VA_ARGS__)
/********************************************************/
/* rc4030 emulation */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 11/16] rc4030: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 11/16] rc4030: " Marc Marí
@ 2014-05-13 9:16 ` Marc Marí
0 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 9:16 UTC (permalink / raw)
To: Marc Marí
Cc: Stefan Hajnoczi, Peter Crosthwaite, qemu-devel,
Andreas Färber
El Tue, 13 May 2014 09:02:47 +0200
Marc Marí <marc.mari.barcelo@gmail.com> escribió:
> hw/dma/rc4030.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/hw/dma/rc4030.c b/hw/dma/rc4030.c
> index af26632..84f9f33 100644
> --- a/hw/dma/rc4030.c
> +++ b/hw/dma/rc4030.c
> @@ -32,17 +32,16 @@
> //#define DEBUG_RC4030
> //#define DEBUG_RC4030_DMA
>
> -#ifdef DEBUG_RC4030
> -#define DPRINTF(fmt, ...) \
> -do { printf("rc4030: " fmt , ## __VA_ARGS__); } while (0)
> static const char* irq_names[] = { "parallel", "floppy", "sound",
> "video", "network", "scsi", "keyboard", "mouse", "serial0",
> "serial1" }; +#ifdef DEBUG_RC4030
> +#define DEBUG_RC4030_ENABLED 1
> #else
> -#define DPRINTF(fmt, ...)
> +#define DEBUG_RC4030_ENABLED 0
> #endif
>
> -#define RC4030_ERROR(fmt, ...) \
> -do { fprintf(stderr, "rc4030 ERROR: %s: " fmt, __func__ , ##
> __VA_ARGS__); } while (0) +#define DPRINTF(fmt, ...)
> QEMU_DPRINTF(DEBUG_RC4030_ENABLED, "rc4030", fmt, ## __VA_ARGS__)
> +#define RC4030_ERROR(fmt, ...) QEMU_DPRINTF(1, "rc4030 ERROR", fmt,
> ##
> __VA_ARGS__) /********************************************************/ /*
> rc4030 emulation */
This file debugs to stdout. Modifying it was a misreading. printfs in
the code can be changed to fprintfs to stderr or the macro can be left
as it was.
Marc
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 12/16] sd: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (10 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 11/16] rc4030: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 13/16] isa: " Marc Marí
` (3 subsequent siblings)
15 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/sd/sd.c | 7 ++++---
hw/sd/ssi-sd.c | 14 +++++++-------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 4502ad1..4a11466 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -37,12 +37,13 @@
//#define DEBUG_SD 1
#ifdef DEBUG_SD
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, "SD: " fmt , ## __VA_ARGS__); } while (0)
+#define DEBUG_SD_ENABLED 1
#else
-#define DPRINTF(fmt, ...) do {} while(0)
+#define DEBUG_SD_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_SD_ENABLED, "SD", fmt, ## __VA_ARGS__)
+
#define ACMD41_ENQUIRY_MASK 0x00ffffff
typedef enum {
diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index b012e57..8048056 100644
--- a/hw/sd/ssi-sd.c
+++ b/hw/sd/ssi-sd.c
@@ -17,16 +17,16 @@
//#define DEBUG_SSI_SD 1
#ifdef DEBUG_SSI_SD
-#define DPRINTF(fmt, ...) \
-do { printf("ssi_sd: " fmt , ## __VA_ARGS__); } while (0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "ssi_sd: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
+#define DEBUG_SSI_SD_ENABLED 1
#else
-#define DPRINTF(fmt, ...) do {} while(0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "ssi_sd: error: " fmt , ## __VA_ARGS__);} while (0)
+#define DEBUG_SSI_SD_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_SSI_SD_ENABLED, "ssi_sd", fmt, ## __VA_ARGS__)
+#define BADF(fmt, ...) \
+ QEMU_DPRINTF(1, "ssi_sd error", fmt, ## __VA_ARGS__); \
+ do { if(DEBUG_SSI_SD_ENABLED) { exit(1); } } while (0)
+
typedef enum {
SSI_SD_CMD,
SSI_SD_CMDARG,
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 13/16] isa: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (11 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 12/16] sd: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 14/16] lan9118: " Marc Marí
` (2 subsequent siblings)
15 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/isa/vt82c686.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 1a93afd..5184e4b 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -29,11 +29,13 @@
//#define DEBUG_VT82C686B
#ifdef DEBUG_VT82C686B
-#define DPRINTF(fmt, ...) fprintf(stderr, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__)
+#define DEBUG_VT82C686B_ENABLED 1
#else
-#define DPRINTF(fmt, ...)
+#define DEBUG_VT82C686B_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_VT82C686B_ENABLED, "vt82c686", fmt, ## __VA_ARGS__)
+
typedef struct SuperIOConfig
{
uint8_t config[0xff];
@@ -53,7 +55,7 @@ static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data,
int can_write;
SuperIOConfig *superio_conf = opaque;
- DPRINTF("superio_ioport_writeb address 0x%x val 0x%x\n", addr, data);
+ DPRINTF("superio_ioport_writeb address 0x%x val 0x%x\n", (unsigned)addr, (unsigned)data);
if (addr == 0x3f0) {
superio_conf->index = data & 0xff;
} else {
@@ -99,7 +101,7 @@ static uint64_t superio_ioport_readb(void *opaque, hwaddr addr, unsigned size)
{
SuperIOConfig *superio_conf = opaque;
- DPRINTF("superio_ioport_readb address 0x%x\n", addr);
+ DPRINTF("superio_ioport_readb address 0x%x\n", (unsigned)addr);
return (superio_conf->config[superio_conf->index]);
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 14/16] lan9118: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (12 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 13/16] isa: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 15/16] pci-host: " Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 16/16] common: " Marc Marí
15 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/net/lan9118.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index e528290..5f43ab6 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -21,16 +21,22 @@
//#define DEBUG_LAN9118
#ifdef DEBUG_LAN9118
-#define DPRINTF(fmt, ...) \
-do { printf("lan9118: " fmt , ## __VA_ARGS__); } while (0)
-#define BADF(fmt, ...) \
-do { hw_error("lan9118: error: " fmt , ## __VA_ARGS__);} while (0)
+#define DEBUG_LAN9118_ENABLED 1
#else
-#define DPRINTF(fmt, ...) do {} while(0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "lan9118: error: " fmt , ## __VA_ARGS__);} while (0)
+#define DEBUG_LAN9118_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_LAN9118_ENABLED, "lan9118", fmt, ## __VA_ARGS__)
+
+#define BADF(fmt, ...) \
+ do { \
+ if(DEBUG_LAN9118_ENABLED) { \
+ hw_error("lan9118: error: " fmt , ## __VA_ARGS__); \
+ }else{ \
+ fprintf(stderr, "lan9118: error: " fmt , ## __VA_ARGS__); \
+ } \
+ } while (0)
+
#define CSR_ID_REV 0x50
#define CSR_IRQ_CFG 0x54
#define CSR_INT_STS 0x58
@@ -1031,7 +1037,7 @@ static void lan9118_writel(void *opaque, hwaddr offset,
s->int_sts |= val & SW_INT;
break;
case CSR_FIFO_INT:
- DPRINTF("FIFO INT levels %08x\n", val);
+ DPRINTF("FIFO INT levels %08x\n", (unsigned)val);
s->fifo_int = val;
break;
case CSR_RX_CFG:
@@ -1112,9 +1118,9 @@ static void lan9118_writel(void *opaque, hwaddr offset,
if (val & 0x80000000) {
if (val & 0x40000000) {
s->mac_data = do_mac_read(s, val & 0xf);
- DPRINTF("MAC read %d = 0x%08x\n", val & 0xf, s->mac_data);
+ DPRINTF("MAC read %d = 0x%08x\n", (unsigned)(val & 0xf), s->mac_data);
} else {
- DPRINTF("MAC write %d = 0x%08x\n", val & 0xf, s->mac_data);
+ DPRINTF("MAC write %d = 0x%08x\n", (unsigned)(val & 0xf), s->mac_data);
do_mac_write(s, val & 0xf, s->mac_data);
}
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 15/16] pci-host: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (13 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 14/16] lan9118: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 9:13 ` Marc Marí
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 16/16] common: " Marc Marí
15 siblings, 1 reply; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
hw/pci-host/bonito.c | 10 ++++++----
hw/pci-host/ppce500.c | 8 ++++++--
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index 902441f..4a1dd20 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -50,11 +50,13 @@
//#define DEBUG_BONITO
#ifdef DEBUG_BONITO
-#define DPRINTF(fmt, ...) fprintf(stderr, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__)
+#define DEBUG_BONITO_ENABLED 1
#else
-#define DPRINTF(fmt, ...)
+#define DEBUG_BONITO_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_BONITO_ENABLED, "bonito", fmt, ## __VA_ARGS__)
+
/* from linux soure code. include/asm-mips/mips-boards/bonito64.h*/
#define BONITO_BOOT_BASE 0x1fc00000
#define BONITO_BOOT_SIZE 0x00100000
@@ -235,7 +237,7 @@ static void bonito_writel(void *opaque, hwaddr addr,
saddr = (addr - BONITO_REGBASE) >> 2;
- DPRINTF("bonito_writel "TARGET_FMT_plx" val %x saddr %x\n", addr, val, saddr);
+ DPRINTF("bonito_writel "TARGET_FMT_plx" val %x saddr %x\n", addr, (unsigned)val, saddr);
switch (saddr) {
case BONITO_BONPONCFG:
case BONITO_IODEVCFG:
@@ -322,7 +324,7 @@ static void bonito_pciconf_writel(void *opaque, hwaddr addr,
PCIBonitoState *s = opaque;
PCIDevice *d = PCI_DEVICE(s);
- DPRINTF("bonito_pciconf_writel "TARGET_FMT_plx" val %x\n", addr, val);
+ DPRINTF("bonito_pciconf_writel "TARGET_FMT_plx" val %x\n", addr, (unsigned)val);
d->config_write(d, addr, val, 4);
}
diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c
index c80b7cb..dfeb19e 100644
--- a/hw/pci-host/ppce500.c
+++ b/hw/pci-host/ppce500.c
@@ -21,12 +21,16 @@
#include "qemu/bswap.h"
#include "hw/pci-host/ppce500.h"
+//#define DEBUG_PCI
+
#ifdef DEBUG_PCI
-#define pci_debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
+#define DEBUG_PCI_ENABLED 1
#else
-#define pci_debug(fmt, ...)
+#define DEBUG_PCI_ENABLED 0
#endif
+#define pci_debug(fmt, ...) QEMU_DPRINTF(DEBUG_PCI_ENABLED, "ppce500", fmt, ## __VA_ARGS__)
+
#define PCIE500_CFGADDR 0x0
#define PCIE500_CFGDATA 0x4
#define PCIE500_REG_BASE 0xC00
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 15/16] pci-host: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 15/16] pci-host: " Marc Marí
@ 2014-05-13 9:13 ` Marc Marí
0 siblings, 0 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 9:13 UTC (permalink / raw)
To: Marc Marí
Cc: Stefan Hajnoczi, Peter Crosthwaite, qemu-devel,
Andreas Färber
El Tue, 13 May 2014 09:02:51 +0200
Marc Marí <marc.mari.barcelo@gmail.com> escribió:
> diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c
> index c80b7cb..dfeb19e 100644
> --- a/hw/pci-host/ppce500.c
> +++ b/hw/pci-host/ppce500.c
> @@ -21,12 +21,16 @@
> #include "qemu/bswap.h"
> #include "hw/pci-host/ppce500.h"
>
> +//#define DEBUG_PCI
> +
> #ifdef DEBUG_PCI
> -#define pci_debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
> +#define DEBUG_PCI_ENABLED 1
> #else
> -#define pci_debug(fmt, ...)
> +#define DEBUG_PCI_ENABLED 0
> #endif
>
> +#define pci_debug(fmt, ...) QEMU_DPRINTF(DEBUG_PCI_ENABLED,
> "ppce500", fmt, ## __VA_ARGS__) +
> #define PCIE500_CFGADDR 0x0
> #define PCIE500_CFGDATA 0x4
> #define PCIE500_REG_BASE 0xC00
In this file, the function name is already written to the macro, so now
it will appear two times. The calls to the macro can be changed to not
add the function name, which, in my opinion, is a bit nicer.
Marc
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH v2 16/16] common: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 [Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs Marc Marí
` (14 preceding siblings ...)
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 15/16] pci-host: " Marc Marí
@ 2014-05-13 7:02 ` Marc Marí
2014-05-13 9:05 ` Cornelia Huck
2014-05-13 15:21 ` Eric Blake
15 siblings, 2 replies; 32+ messages in thread
From: Marc Marí @ 2014-05-13 7:02 UTC (permalink / raw)
To: qemu-devel
Cc: Marc Marí, Stefan Hajnoczi, Peter Crosthwaite,
Andreas Färber
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.
As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
include/qemu-common.h | 7 +++++++
migration-rdma.c | 32 ++++++++++++++------------------
page_cache.c | 10 ++++++----
3 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/include/qemu-common.h b/include/qemu-common.h
index 3f3fd60..3593bdc 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -463,3 +463,10 @@ int parse_debug_env(const char *name, int max, int initial);
const char *qemu_ether_ntoa(const MACAddr *mac);
#endif
+
+#define QEMU_DPRINTF(cond,pfx,fmt,...) \
+ do { \
+ if (cond) { \
+ fprintf(stderr, pfx": %s:"fmt, __func__, ## __VA_ARGS__); \
+ } \
+ } while (0)
diff --git a/migration-rdma.c b/migration-rdma.c
index eeb4302..9f9fa8d 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -32,39 +32,35 @@
//#define DEBUG_RDMA_REALLY_VERBOSE
#ifdef DEBUG_RDMA
-#define DPRINTF(fmt, ...) \
- do { printf("rdma: " fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_RDMA_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_RDMA_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_RDMA_ENABLED, "rdma", fmt, ## __VA_ARGS__)
+
#ifdef DEBUG_RDMA_VERBOSE
-#define DDPRINTF(fmt, ...) \
- do { printf("rdma: " fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_RDMA_VERBOSE_ENABLED 1
#else
-#define DDPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_RDMA_VERBOSE_ENABLED 0
#endif
+#define DDPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_RDMA_VERBOSE_ENABLED, "rdma", fmt, ## __VA_ARGS__)
+
#ifdef DEBUG_RDMA_REALLY_VERBOSE
-#define DDDPRINTF(fmt, ...) \
- do { printf("rdma: " fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_RDMA_REALLY_VERBOSE_ENABLED 1
#else
-#define DDDPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_RDMA_REALLY_VERBOSE_ENABLED 0
#endif
+#define DDDPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_RDMA_REALLY_VERBOSE_ENABLED, "rdma", fmt, ## __VA_ARGS__)
+
/*
* Print and error on both the Monitor and the Log file.
*/
#define ERROR(errp, fmt, ...) \
- do { \
- fprintf(stderr, "RDMA ERROR: " fmt "\n", ## __VA_ARGS__); \
- if (errp && (*(errp) == NULL)) { \
- error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); \
- } \
- } while (0)
+ QEMU_DPRINTF(1, "RDMA ERROR", fmt"\n", ## __VA_ARGS__); \
+ do { if (errp && (*(errp) == NULL)) { error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); } } while (0)
#define RDMA_RESOLVE_TIMEOUT_MS 10000
diff --git a/page_cache.c b/page_cache.c
index b033681..514d8c0 100644
--- a/page_cache.c
+++ b/page_cache.c
@@ -25,14 +25,16 @@
#include "qemu-common.h"
#include "migration/page_cache.h"
+//#define DEBUG_CACHE 1
+
#ifdef DEBUG_CACHE
-#define DPRINTF(fmt, ...) \
- do { fprintf(stdout, "cache: " fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_CACHE_ENABLED 1
#else
-#define DPRINTF(fmt, ...) \
- do { } while (0)
+#define DEBUG_CACHE_ENABLED 0
#endif
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_CACHE_ENABLED, "cache", fmt, ## __VA_ARGS__)
+
typedef struct CacheItem CacheItem;
struct CacheItem {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 16/16] common: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 16/16] common: " Marc Marí
@ 2014-05-13 9:05 ` Cornelia Huck
2014-05-13 15:21 ` Eric Blake
1 sibling, 0 replies; 32+ messages in thread
From: Cornelia Huck @ 2014-05-13 9:05 UTC (permalink / raw)
To: Marc Marí
Cc: Stefan Hajnoczi, Peter Crosthwaite, qemu-devel,
Andreas Färber
On Tue, 13 May 2014 09:02:52 +0200
Marc Marí <marc.mari.barcelo@gmail.com> wrote:
> Modify debug macros to have the same format through the codebase and use regular
> ifs instead of ifdef.
>
> As the debug printf is always put in code, some casting had to be added to avoid
> warnings treated as errors at compile time.
>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
> include/qemu-common.h | 7 +++++++
> migration-rdma.c | 32 ++++++++++++++------------------
> page_cache.c | 10 ++++++----
> 3 files changed, 27 insertions(+), 22 deletions(-)
>
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index 3f3fd60..3593bdc 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -463,3 +463,10 @@ int parse_debug_env(const char *name, int max, int initial);
> const char *qemu_ether_ntoa(const MACAddr *mac);
>
> #endif
> +
> +#define QEMU_DPRINTF(cond,pfx,fmt,...) \
> + do { \
> + if (cond) { \
> + fprintf(stderr, pfx": %s:"fmt, __func__, ## __VA_ARGS__); \
> + } \
> + } while (0)
I'd split that hunk into a seperate patch and make it the first one in
the series. That way, you'd preserve bisectability.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH v2 16/16] common: Convert conditional compilation of debug printfs to regular ifs
2014-05-13 7:02 ` [Qemu-devel] [PATCH v2 16/16] common: " Marc Marí
2014-05-13 9:05 ` Cornelia Huck
@ 2014-05-13 15:21 ` Eric Blake
1 sibling, 0 replies; 32+ messages in thread
From: Eric Blake @ 2014-05-13 15:21 UTC (permalink / raw)
To: Marc Marí, qemu-devel
Cc: Stefan Hajnoczi, Peter Crosthwaite, Andreas Färber
[-- Attachment #1: Type: text/plain, Size: 2534 bytes --]
On 05/13/2014 01:02 AM, Marc Marí wrote:
> Modify debug macros to have the same format through the codebase and use regular
> ifs instead of ifdef.
>
> As the debug printf is always put in code, some casting had to be added to avoid
> warnings treated as errors at compile time.
>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
> include/qemu-common.h | 7 +++++++
> migration-rdma.c | 32 ++++++++++++++------------------
> page_cache.c | 10 ++++++----
> 3 files changed, 27 insertions(+), 22 deletions(-)
>
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index 3f3fd60..3593bdc 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -463,3 +463,10 @@ int parse_debug_env(const char *name, int max, int initial);
> const char *qemu_ether_ntoa(const MACAddr *mac);
>
> #endif
> +
> +#define QEMU_DPRINTF(cond,pfx,fmt,...) \
> + do { \
> + if (cond) { \
> + fprintf(stderr, pfx": %s:"fmt, __func__, ## __VA_ARGS__); \
Another instance of using the gcc extension ##__VA_ARGS__, when you
could be portable to all C99 compilers by just subsuming fmt into the '...'.
Spacing doesn't match normal style; need space after comma, and use
indentation of 4 spaces not 2. It should be:
#define QEMU_DPRINTF(cond, pfx, fmt, ...) \
do { \
if (cond) { \
......
I'm not sure whether the code base has a definite preference towards
lining up \ continuations in the same column.
I agree with the other review comments that this hunk needs to be first
in the series - each patch must pass 'make' on its own, but your series
as sent fails to compile earlier patches until this hunk is in.
> */
> #define ERROR(errp, fmt, ...) \
> - do { \
> - fprintf(stderr, "RDMA ERROR: " fmt "\n", ## __VA_ARGS__); \
> - if (errp && (*(errp) == NULL)) { \
> - error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); \
> - } \
> - } while (0)
> + QEMU_DPRINTF(1, "RDMA ERROR", fmt"\n", ## __VA_ARGS__); \
> + do { if (errp && (*(errp) == NULL)) { error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); } } while (0)
Once again, you broke a one-statement macro into multiple statements.
Fix the placement of "do {".
Pre-existing, but you might as well simplify the code to drop redundant
() and comparison to NULL:
if (errp && !*errp) {
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 32+ messages in thread