[Spice-devel] [PATHCH win-qxl 4/8] display/qxldd.h: add DEBUG_PRINT_ONCE
Hans de Goede
hdegoede at redhat.com
Fri Apr 8 02:48:12 PDT 2011
Hi,
nit pick, the usual way to do preprocessor macros with { } is:
#define foo(x) \
do { \
bar \
} while (0)
This way you don't end up with a stray ; after the
} which sometimes can lead to issues / warnings.
IE:
if (x)
foo(x);
else
...
Would not work with your way because it would expand to:
if (x)
{
...
};
else
And the ; makes the compiler not expect else, since there
are now 2 statements between the if and the else
Regards,
Hans
On 04/07/2011 06:10 PM, Alon Levy wrote:
> ---
> display/qxldd.h | 9 +++++++++
> 1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/display/qxldd.h b/display/qxldd.h
> index 0f90af1..7130b47 100644
> --- a/display/qxldd.h
> +++ b/display/qxldd.h
> @@ -44,6 +44,15 @@
>
> #define DEBUG_PRINT(arg) DebugPrint arg
>
> +#define DEBUG_PRINT_ONCE(arg) \
> + { \
> + static int run = 0; \
> + if (!run) { \
> + run = 1; \
> + DebugPrint arg; \
> + } \
> + }
> +
> #ifdef DBG
> #define ASSERT(pdev, x) if (!(x)) { \
> DebugPrint(pdev, 0, "ASSERT(%s) failed @ %s\n", #x, __FUNCTION__); \
More information about the Spice-devel
mailing list