[Piglit] [PATCH] arb_cull_distance: Fix sometimes-uninitialized warnings.

Vinson Lee vlee at freedesktop.org
Sat Mar 4 23:14:29 UTC 2017


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 at freedesktop.org>
---
 tests/spec/arb_cull_distance/exceed-limits.c | 2 ++
 1 file changed, 2 insertions(+)

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;
-- 
2.9.3



More information about the Piglit mailing list