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

Jose Fonseca jfonseca at vmware.com
Tue Dec 6 01:25:53 PST 2011


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."

That is, it should be

  while (glGetError() != GL_NO_ERROR)
     ;

which would be more useful if implemented as a macro, e.g., "RESET_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