qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-2.10 03/10] s390x/pci: make printf always co


From: Cornelia Huck
Subject: Re: [Qemu-devel] [PATCH for-2.10 03/10] s390x/pci: make printf always compile in debug output
Date: Thu, 6 Apr 2017 15:07:08 +0200

On Thu, 6 Apr 2017 14:15:45 +0200
Thomas Huth <address@hidden> wrote:

> On 06.04.2017 13:16, Cornelia Huck wrote:
> > From: Danil Antonov <address@hidden>
> > 
> > Wrapped printf calls inside debug macros (DPRINTF) in `if` statement.
> > This will ensure that printf function will always compile even if debug
> > output is turned off and, in turn, will prevent bitrot of the format
> > strings.
> > 
> > Signed-off-by: Danil Antonov <address@hidden>
> > Message-Id: <address@hidden>
> > Signed-off-by: Cornelia Huck <address@hidden>
> > ---
> >  hw/s390x/s390-pci-bus.c  | 16 ++++++++++------
> >  hw/s390x/s390-pci-inst.c | 16 ++++++++++------
> >  2 files changed, 20 insertions(+), 12 deletions(-)
> > 
> > diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
> > index 69b0291e8a..0f62363434 100644
> > --- a/hw/s390x/s390-pci-bus.c
> > +++ b/hw/s390x/s390-pci-bus.c
> > @@ -24,14 +24,18 @@
> >  #include "qemu/error-report.h"
> >  
> >  /* #define DEBUG_S390PCI_BUS */
> 
> This comment is now somewhat misleading. If you uncomment this "#define
> DEBUG_S390PCI_BUS" (without adding a "1" at the end), you end up with
> some empty "if ()" statements now, i.e. compilation failures. So I'd
> like to suggest to simply remove the above line.

Yeah, makes sense, and also matches what is done in the s390x/kvm patch.
I'll merge that in.

> 
> > -#ifdef DEBUG_S390PCI_BUS
> > -#define DPRINTF(fmt, ...) \
> > -    do { fprintf(stderr, "S390pci-bus: " fmt, ## __VA_ARGS__); } while (0)
> > -#else
> > -#define DPRINTF(fmt, ...) \
> > -    do { } while (0)
> > +
> > +#ifndef DEBUG_S390PCI_BUS
> > +#define DEBUG_S390PCI_BUS  0
> >  #endif
> >  
> > +#define DPRINTF(fmt, ...)                                         \
> > +    do {                                                          \
> > +        if (DEBUG_S390PCI_BUS) {                                  \
> > +            fprintf(stderr, "S390pci-bus: " fmt, ## __VA_ARGS__); \
> > +        }                                                         \
> > +    } while (0)
> > +




reply via email to

[Prev in Thread] Current Thread [Next in Thread]