qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] debug: made printf always compile in debug outp


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] debug: made printf always compile in debug output
Date: Mon, 3 Apr 2017 16:19:53 +0100
User-agent: Mutt/1.8.0 (2017-02-23)

On Mon, Mar 27, 2017 at 02:50:47PM +0300, Danil Antonov wrote:
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index 2b0f3e1..bf880c1 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -39,13 +39,16 @@
>  #include "qom/qom-qobject.h"
>  #include "qapi/qmp/qint.h"
> 
> -//#define DEBUG
> 
> -#ifdef DEBUG
> -# define ACPI_PCIHP_DPRINTF(format, ...)     printf(format, ## __VA_ARGS__)
> -#else
> -# define ACPI_PCIHP_DPRINTF(format, ...)     do { } while (0)
> -#endif
> +#ifndef DEBUG
> +#define DEBUG 0
> +#endif
> +
> +#define ACPI_PCIHP_DPRINTF(fmt, ...) do {     \
> +    if (DEBUG) {                              \
> +        fprintf(stderr, fmt, ## __VA_ARGS__); \
> +    }                                         \
> +} while (0);

The semicolon isn't necessary.  The caller provides it.

  ACPI_PCIHP_DPRINTF("foo\n");

It's normal to define statement-like macros with do { ... } while (0)
and no semicolon in the definition.

Attachment: signature.asc
Description: PGP signature


reply via email to

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