arb_program_interface_query: Silence uninitialized variable warning.

Submitted by Vinson Lee on Dec. 1, 2015, 5:50 a.m.

Details

Message ID 1448949035-23415-1-git-send-email-vlee@freedesktop.org
State New
Headers show
Series "arb_program_interface_query: Silence uninitialized variable warning." ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Vinson Lee Dec. 1, 2015, 5:50 a.m.
Fixes Coverity "uninitialized scalar variable" defect.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
---
 tests/spec/arb_program_interface_query/getprogramresourceiv.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/tests/spec/arb_program_interface_query/getprogramresourceiv.c b/tests/spec/arb_program_interface_query/getprogramresourceiv.c
index 769e29f..7ef72cc 100755
--- a/tests/spec/arb_program_interface_query/getprogramresourceiv.c
+++ b/tests/spec/arb_program_interface_query/getprogramresourceiv.c
@@ -668,6 +668,9 @@  check_prop(GLuint prog, GLenum programInterface, int index, const char *name,
 		case GL_BUFFER_VARIABLE:
 			pif = GL_SHADER_STORAGE_BLOCK;
 			break;
+		default:
+			assert(0);
+			pif = GL_NONE;
 		}
 
 		parent_idx = glGetProgramResourceIndex(prog, pif,
@@ -739,6 +742,9 @@  check_prop(GLuint prog, GLenum programInterface, int index, const char *name,
 		case GL_COMPUTE_SUBROUTINE_UNIFORM:
 			pif = GL_COMPUTE_SUBROUTINE;
 			break;
+		default:
+			assert(0);
+			pif = GL_NONE;
 		}
 
 		/* check that the return count is as expected */

Comments

On 11/30/2015 10:50 PM, Vinson Lee wrote:
> Fixes Coverity "uninitialized scalar variable" defect.
>
> Signed-off-by: Vinson Lee <vlee@freedesktop.org>
> ---
>   tests/spec/arb_program_interface_query/getprogramresourceiv.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/tests/spec/arb_program_interface_query/getprogramresourceiv.c b/tests/spec/arb_program_interface_query/getprogramresourceiv.c
> index 769e29f..7ef72cc 100755
> --- a/tests/spec/arb_program_interface_query/getprogramresourceiv.c
> +++ b/tests/spec/arb_program_interface_query/getprogramresourceiv.c
> @@ -668,6 +668,9 @@ check_prop(GLuint prog, GLenum programInterface, int index, const char *name,
>   		case GL_BUFFER_VARIABLE:
>   			pif = GL_SHADER_STORAGE_BLOCK;
>   			break;
> +		default:
> +			assert(0);
> +			pif = GL_NONE;

In mesa we have an unreachable() macro, but I don't think we have that 
in piglit yet, AFAIK.

In any case, I try to avoid generic assert(0) and use something with a 
bit more info such as:

assert(!"unexpected programInterface value");

-Brian


>   		}
>
>   		parent_idx = glGetProgramResourceIndex(prog, pif,
> @@ -739,6 +742,9 @@ check_prop(GLuint prog, GLenum programInterface, int index, const char *name,
>   		case GL_COMPUTE_SUBROUTINE_UNIFORM:
>   			pif = GL_COMPUTE_SUBROUTINE;
>   			break;
> +		default:
> +			assert(0);
> +			pif = GL_NONE;
>   		}
>
>   		/* check that the return count is as expected */
>