[Mesa-dev] [PATCH 1/5] intel: Add a macro for printing a debug warning once.

Jason Wood sandain at hotmail.com
Mon Oct 15 08:41:57 PDT 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/12/2012 04:30 PM, Eric Anholt wrote:
> There are a number of places where some obscure piece of the code
> is not currently worth fixing, and we have some workaround behavior
> available.  It's nicer for users to do some lame workaround than to
> just assert, but without asserts we never knew when the workaround
> was at fault.
> 
> This should give us a nice compromise: Execute the workaround, but
> mention that the obscure workaround was hit. --- 
> src/mesa/drivers/dri/intel/intel_context.h |   11 +++++++++++ 1
> file changed, 11 insertions(+)
> 
> diff --git a/src/mesa/drivers/dri/intel/intel_context.h
> b/src/mesa/drivers/dri/intel/intel_context.h index b732696..eeefadf
> 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++
> b/src/mesa/drivers/dri/intel/intel_context.h @@ -483,6 +483,17 @@
> extern int INTEL_DEBUG; dbg_printf(__VA_ARGS__);			\ } while(0)
> 
> +#define WARN_ONCE(cond, fmt...) do {                            \ 
> +   if (unlikely(cond)) {                                        \ 
> +      static bool _warned = false;                              \ 
> +      if (!_warned) {                                           \

I could be wrong here because I'm not super familiar with how macros
work..

It looks like this if statement will _always_ evaluate to true given
that you just initialized the value in the previous line.  I assume
this is not the behavior that you were after.

Cheers,
Jason Wood


> +         fprintf(stderr, "WARNING: ");                          \ 
> +         fprintf(stderr, fmt);                                  \ 
> +         _warned = true;                                        \ 
> +      }                                                         \ 
> +   }                                                            \ 
> +} while (0) + #define PCI_CHIP_845_G			0x2562 #define
> PCI_CHIP_I830_M			0x3577 #define PCI_CHIP_I855_GM		0x3582
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQEcBAEBAgAGBQJQfC7FAAoJEKeoMFRQQB/oHrsH/3XS6pGuRs40Q08lLxnHZzC3
wljvwjZCx1UyNn1zaEDIlM0S7g+wm9KnSt676K2GY35jY3/l7HRkLpoX0E8nIg7z
rRkChxA7E3tTcKljgdOwZaeiZFImPDn+9KJtStqgqzG3g31oFIzBp3xlboYjrBJC
6xSCfPeN69XY8/LfoVnz2r6O1Ls2wm7b3W0PQnUIty2TdE+DugCo8ah21vyhXKWU
n62KwGUwHTda+To0P3zfswX2I4Q60KYKvT+nl+W2mceeCE5O8fArY7EoZpG/PQx9
Id9WBS2P7F9YY1Gav6XDfJE7HdUnEOzHFW1paeVf5CE0bFkEj1V2kuC1FxzqJYA=
=M8ky
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list