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

Matt Turner mattst88 at gmail.com
Mon Oct 15 11:10:21 PDT 2012


On Mon, Oct 15, 2012 at 8:41 AM, Jason Wood <sandain at hotmail.com> wrote:
> -----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.

_warned has a static initializer, so it's initialized at runtime and
never again.


More information about the mesa-dev mailing list