qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 01/14] dma: Convert conditional compilation of d


From: Marc Marí
Subject: Re: [Qemu-devel] [PATCH 01/14] dma: Convert conditional compilation of debug printfs to regular ifs
Date: Mon, 28 Apr 2014 13:32:24 +0200

2014-04-28 11:05 GMT+02:00 Michael Tokarev <address@hidden>:
>
> 28.04.2014 12:26, Marc Marí пишет:
> > From: Marc Marí <address@hidden>
> >
> > Modify debug macros as explained in https://lists.gnu.org/archive/html/qemu-devel/2014-04/msg03642.html
> >
> > Signed-off-by: Marc Marí <address@hidden>
> > ---
> >  hw/dma/i82374.c |   17 ++++++++++-------
> >  hw/dma/i8257.c  |   24 +++++++++++++++++-------
> >  hw/dma/rc4030.c |   13 +++++++++----
> >  3 files changed, 36 insertions(+), 18 deletions(-)
> >
> > diff --git a/hw/dma/i82374.c b/hw/dma/i82374.c
> > index dc7a767..fff4e6f 100644
> > --- a/hw/dma/i82374.c
> > +++ b/hw/dma/i82374.c
> > @@ -24,15 +24,18 @@
> >
> >  #include "hw/isa/isa.h"
> >
> > -//#define DEBUG_I82374
> > +//#define DEBUG_I82374 1
> >
> > -#ifdef DEBUG_I82374
> > -#define DPRINTF(fmt, ...) \
> > -do { fprintf(stderr, "i82374: " fmt , ## __VA_ARGS__); } while (0)
> > -#else
> > -#define DPRINTF(fmt, ...) \
> > -do {} while (0)
> > +#ifndef DEBUG_I82374
> > +#define DEBUG_I82374 0
> >  #endif
> > +
> > +#define DPRINTF(fmt, ...) \
> > +    do { \
> > +        if(DEBUG_I82374) { \
> > +            fprintf(stderr, "I82374: " fmt, ## __VA_ARGS__); \
> > +        } \
> > +    } while (0)
>
> Since this is the same pattern in all files touched, it can be generalized:
>
> qemu-common.h:
>
> #define QEMU_DPRINTF(cond,pfx,fmt,...) \
>   do { \
>     if (cond) {
>       fprintf(stderr, pfx # ": " fmt, ## __VA_ARGS__); \
>     } \
>   while(0)
>
> This file (and other):
>
> #ifndef DEBUG_I82374
> #define DEBUG_I82374 0
> #endif
> #define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_I82374, "I82374", fmt, ## __VA_ARGS__)
>
>
> which is just 4 lines per file.
>
> FWIW.
>
> Thanks,
>
> /mjt

Approximately 1/3 cannot be forced into the same pattern (do not use fprintf(stderr), mainly). I'll change the ones that are possible for v2.

reply via email to

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