diff mbox

[v2,02/16] s390: Convert conditional compilation of debug printfs to regular ifs

Message ID 1399964572-5376-3-git-send-email-marc.mari.barcelo@gmail.com
State New
Headers show

Commit Message

Marc Marí May 13, 2014, 7:02 a.m. UTC
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(-)

Comments

Cornelia Huck May 13, 2014, 9:04 a.m. UTC | #1
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
Eric Blake May 13, 2014, 2:45 p.m. UTC | #2
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(-)
>
diff mbox

Patch

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