[Piglit] [PATCH] gl-4.5: Fix sometimes-uninitialized warning.

Alejandro Piñeiro apinheiro at igalia.com
Thu Feb 16 08:11:28 UTC 2017


Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>

On 15/02/17 23:31, Vinson Lee wrote:
> compare-framebuffer-parameter-with-get.c:143:14: warning: variable 'found' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
>         for (i = 0; i < ARRAY_SIZE(table_23_73_allowed); i++) {
>                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> compare-framebuffer-parameter-with-get.c:150:7: note: uninitialized use occurs here
>         if (!found) {
>              ^~~~~
> compare-framebuffer-parameter-with-get.c:143:14: note: remove the condition if it is always true
>         for (i = 0; i < ARRAY_SIZE(table_23_73_allowed); i++) {
>                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> compare-framebuffer-parameter-with-get.c:130:12: note: initialize the variable 'found' to silence this warning
>         bool found;
>                   ^
>                    = false
>
> Fixes: d60f1fb839bc ("gl-4.5/compare-framebuffer-parameter-with-get: add test")
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
>  tests/spec/gl-4.5/compare-framebuffer-parameter-with-get.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/spec/gl-4.5/compare-framebuffer-parameter-with-get.c b/tests/spec/gl-4.5/compare-framebuffer-parameter-with-get.c
> index b10a780b70ac..a5985bfcd1e7 100644
> --- a/tests/spec/gl-4.5/compare-framebuffer-parameter-with-get.c
> +++ b/tests/spec/gl-4.5/compare-framebuffer-parameter-with-get.c
> @@ -127,7 +127,7 @@ static void
>  parse_args(int argc, char **argv)
>  {
>  	int i;
> -	bool found;
> +	bool found = false;
>  
>  	if (argc > 3) {
>  		printf("Only two possible params supported\n");



More information about the Piglit mailing list