[Piglit] [PATCH] arb_uniform_buffer_object: Silence uninitialized variable warnings.

Ian Romanick idr at freedesktop.org
Mon Feb 10 19:42:47 PST 2014


On 01/29/2014 08:31 PM, Vinson Lee wrote:
> This patch silences these Clang sometimes-uninitialized warnings.

Would marking up piglit_report_result in tests/util/piglit-util.h with a
"noreturn" function attribute also silence clang?  That seems the better
option... it should prevent future such (false) warnings.

> 
> maxuniformblocksize.c:158:2: warning: variable 'vs_source' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
>         default:
>         ^~~~~~~
> maxuniformblocksize.c:162:52: note: uninitialized use occurs here
>         vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
>                                                           ^~~~~~~~~
> maxuniformblocksize.c:106:17: note: initialize the variable 'vs_source' to silence this warning
>         char *vs_source, *fs_source;
>                        ^
>                         = NULL
> maxuniformblocksize.c:158:2: warning: variable 'fs_source' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
>         default:
>         ^~~~~~~
> maxuniformblocksize.c:163:54: note: uninitialized use occurs here
>         fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
>                                                             ^~~~~~~~~
> maxuniformblocksize.c:106:29: note: initialize the variable 'fs_source' to silence this warning
>         char *vs_source, *fs_source;
>                                    ^
>                                     = NULL
> 
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
>  tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c b/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c
> index 720fc5c..bf5f3fd 100644
> --- a/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c
> +++ b/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c
> @@ -156,6 +156,8 @@ piglit_display(void)
>  		printf("Testing FS with uniform block vec4 v[%d]\n", vec4s);
>  		break;
>  	default:
> +		vs_source = NULL;
> +		fs_source = NULL;
>  		piglit_report_result(PIGLIT_FAIL);
>  	}
>  
> 



More information about the Piglit mailing list