[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 01/16] include/qemu-common.h: Add QEMU_DPRINT
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v3 01/16] include/qemu-common.h: Add QEMU_DPRINTF macro |
Date: |
Mon, 19 May 2014 09:28:52 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
On 05/17/2014 05:03 PM, Marc Marí wrote:
> Create this macro to let debug macros to have the same format through the
> codebase and use regular ifs instead of ifdef.
>
> Signed-off-by: Marc Marí <address@hidden>
> ---
> include/qemu-common.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index 3f3fd60..acdcf08 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,...) \
Style: space after comma:
#define QEMU_DPRINTF(cond, pfx, fmt, ...) \
> + do { \
Up to you if you want to align \ rather than putting them flush to each
line (I don't know if there is a prevalent style in the codebase).
> + if (cond) { \
> + fprintf(stderr, pfx": %s:"fmt, __func__, ## __VA_ARGS__); \
Style: spaces between string concatenation:
pfx ": %s:" fmt
This definition requires that pfx and fmt be constant strings to allow
string concatenation. Might it be better to allow for non-constants, by
splitting it into two actions, as in:
fprintf(stderr, "%s: %s:", pfx, __func__);
fprintf(stderr, fmt, ## __VA_ARGS__);
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v3 00/16] Convert debug printfs to QEMU_DPRINTF, Marc Marí, 2014/05/17
- [Qemu-devel] [PATCH v3 01/16] include/qemu-common.h: Add QEMU_DPRINTF macro, Marc Marí, 2014/05/17
- Re: [Qemu-devel] [PATCH v3 01/16] include/qemu-common.h: Add QEMU_DPRINTF macro,
Eric Blake <=
- [Qemu-devel] [PATCH v3 02/16] x86: Convert debug printfs to QEMU_DPRINTF, Marc Marí, 2014/05/17
- [Qemu-devel] [PATCH v3 03/16] s390: Convert debug printfs to QEMU_DPRINTF, Marc Marí, 2014/05/17
- Re: [Qemu-devel] [PATCH v3 03/16] s390: Convert debug printfs to QEMU_DPRINTF, Peter Crosthwaite, 2014/05/18
- Re: [Qemu-devel] [PATCH v3 03/16] s390: Convert debug printfs to QEMU_DPRINTF, Alexander Graf, 2014/05/19
- Re: [Qemu-devel] [PATCH v3 03/16] s390: Convert debug printfs to QEMU_DPRINTF, Marc Marí, 2014/05/19
- Re: [Qemu-devel] [PATCH v3 03/16] s390: Convert debug printfs to QEMU_DPRINTF, Richard Henderson, 2014/05/19
- Re: [Qemu-devel] [PATCH v3 03/16] s390: Convert debug printfs to QEMU_DPRINTF, Peter Crosthwaite, 2014/05/19
- Re: [Qemu-devel] [PATCH v3 03/16] s390: Convert debug printfs to QEMU_DPRINTF, Alexander Graf, 2014/05/19
[Qemu-devel] [PATCH v3 07/16] spapr: Convert debug printfs to QEMU_DPRINTF, Marc Marí, 2014/05/17