qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 05/43] windbg: added helper features


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 05/43] windbg: added helper features
Date: Tue, 26 Sep 2017 12:27:29 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 09/26/2017 12:13 PM, Alistair Francis wrote:

>> +#if (WINDBG_DEBUG_ON)
>> +
>> +# define WINDBG_DEBUG(...) do {    \
>> +    printf("Debug: " __VA_ARGS__); \
>> +    printf("\n");                  \
>> +} while (false)
>> +
>> +# define WINDBG_ERROR(...) do {    \
>> +    printf("Error: " __VA_ARGS__); \
>> +    printf("\n");                  \
>> +} while (false)
> 
> Use qemu_log() instead of printf().
> 
> Have a look as some other files for the usual way we handle debug printing.
> 
>> +
>> +#else
>> +
>> +# define WINDBG_DEBUG(...)
>> +# define WINDBG_ERROR(...) error_report(WINDBG ": " __VA_ARGS__)

What's more - as written, your approach is prone to bit-rot: the
debug/error statements are not compared against -Werror except for the
rare person that enables debugging.  Better is go make the macro
unconditionally expand to something that triggers -Wformat checking, but
guarded by an if(0) for normal use.  Or even switch to trace points
rather than debugging statements, so that you can control at runtime how
much debugging information you want, rather than having to recompile to
turn it on and off.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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