[Piglit] [PATCH] sync_api: Check return value of glGetError.

Ian Romanick idr at freedesktop.org
Wed Dec 7 10:13:51 PST 2011


On 12/06/2011 01:25 AM, Jose Fonseca wrote:
> Coverity knowns that glGetError returns an error? That's quite interesting.
>
> However, I wonder if the purpose of this code is really to check for an error, or to simply "drain" previous errors before glFenceSync() call and the successive error check.  But even in this case, the current code is wrong too, as the glGetError man page says: "Thus, glGetError should always be called  in  a
>   loop, until it returns GL_NO_ERROR, if all error flags are to be reset."

Looking at the rest of the code, I think it is trying to drain any 
previous errors.

> That is, it should be
>
>    while (glGetError() != GL_NO_ERROR)
>       ;
>
> which would be more useful if implemented as a macro, e.g., "RESET_ERROR()".

That's a good idea.  Maybe piglit_reset_gl_error in piglit-util.h near 
the existing piglit_check_gl_error?

> Jose
>
> ----- Original Message -----
>> Fixes Coverity unchecked return value defect.
>>
>> Signed-off-by: Vinson Lee<vlee at vmware.com>
>> ---
>>   tests/general/sync_api.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/tests/general/sync_api.c b/tests/general/sync_api.c
>> index cd9d8c3..e2f9dc0 100644
>> --- a/tests/general/sync_api.c
>> +++ b/tests/general/sync_api.c
>> @@ -108,7 +108,7 @@ piglit_display(void)
>>   	glVertex3f( 0.0,  0.9, -30.0);
>>   	glEnd();
>>
>> -	glGetError();
>> +	assert(glGetError() == 0);
>>
>>   	sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
>>   	FAIL_ON_ERROR("glFenceSync");
>> --
>> 1.7.7.3
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list