arb_cull_distance: Fix sometimes-uninitialized warnings.

Submitted by Vinson Lee on March 4, 2017, 11:14 p.m.

Details

Message ID 1488669269-12387-1-git-send-email-vlee@freedesktop.org
State New
Headers show
Series "arb_cull_distance: Fix sometimes-uninitialized warnings." ( rev: 2 ) in Piglit

Not browsing as part of any series.

Commit Message

Vinson Lee March 4, 2017, 11:14 p.m.
exceed-limits.c:75:6: warning: variable 'clip_distances' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        if (strcmp(argv[1], "cull") == 0) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
exceed-limits.c:90:14: note: uninitialized use occurs here
                 use_clip, clip_distances,
                           ^~~~~~~~~~~~~~
exceed-limits.c:75:2: note: remove the 'if' if its condition is always false
        if (strcmp(argv[1], "cull") == 0) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exceed-limits.c:61:22: note: initialize the variable 'clip_distances' to silence this warning
        GLint clip_distances;
                            ^
                             = 0
exceed-limits.c:78:13: warning: variable 'cull_distances' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        } else if (strcmp(argv[1], "clip") == 0) {
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
exceed-limits.c:91:14: note: uninitialized use occurs here
                 use_cull, cull_distances);
                           ^~~~~~~~~~~~~~
exceed-limits.c:78:9: note: remove the 'if' if its condition is always false
        } else if (strcmp(argv[1], "clip") == 0) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exceed-limits.c:62:22: note: initialize the variable 'cull_distances' to silence this warning
        GLint cull_distances;
                            ^
                             = 0

Fixes: 35469c1b05bb ("Add more ARB_cull_distance tests")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
---
 tests/spec/arb_cull_distance/exceed-limits.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/tests/spec/arb_cull_distance/exceed-limits.c b/tests/spec/arb_cull_distance/exceed-limits.c
index 10fecb969e5c..15304b752db9 100644
--- a/tests/spec/arb_cull_distance/exceed-limits.c
+++ b/tests/spec/arb_cull_distance/exceed-limits.c
@@ -74,9 +74,11 @@  piglit_init(int argc, char **argv)
 
 	if (strcmp(argv[1], "cull") == 0) {
 		use_clip = "// ";
+		clip_distances = 0;
 		cull_distances = max_cull_distances + 2;
 	} else if (strcmp(argv[1], "clip") == 0) {
 		clip_distances = max_clip_distances + 2;
+		cull_distances = 0;
 		use_cull = "// ";
 	} else if (strcmp(argv[1], "total") == 0) {
 		clip_distances = max_combined_clip_and_cull_distances / 2 + 1;