[Mesa-dev] [PATCH 2/2] c11/threads: correct assertion

Jose Fonseca jfonseca at vmware.com
Mon Aug 18 08:15:36 PDT 2014


On 02/08/14 00:16, Ian Romanick wrote:
> On 08/01/2014 09:41 AM, Emil Velikov wrote:
>> We should assert when either the function or the flag pointer
>> is null or we'll end up with a null reference a few lines later.
>>
>> Currently unused by mesa thus it has gone unnoticed.
>>
>> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
>> ---
>>   include/c11/threads_win32.h | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/c11/threads_win32.h b/include/c11/threads_win32.h
>> index 35880ba..a95cb78 100644
>> --- a/include/c11/threads_win32.h
>> +++ b/include/c11/threads_win32.h
>> @@ -296,7 +296,7 @@ static void impl_tss_dtor_invoke()
>>   static inline void
>>   call_once(once_flag *flag, void (*func)(void))
>>   {
>> -    assert(!flag && !func);
>> +    assert(flag && func);
>
> This is why I generally prefer to compare pointers to NULL instead of
> just using them as booleans.
>
>      assert(flag == NULL && func == NULL);
>
> is much more obviously wrong than the current code.  Either way, this
> patch is
>
> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

Yep. My bad.

I added this assertion to see if I could silence MSVC static code 
analyzer's warnings.  It was untested.  And it didn't silence the 
warnings (probably because of this) so I shouldn't have commited it at all.

Jose



More information about the mesa-dev mailing list