blob: 73d539fef27d87907c0f9935a7c30d283d4b3599 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001Upstream-Status: Submitted [mailing list]
2Signed-off-by: Ross Burton <ross.burton@intel.com>
3
4From f0c6981322807e179e39ce67aeebd42cf7a54d36 Mon Sep 17 00:00:00 2001
5From: Ross Burton <ross.burton@intel.com>
6Date: Wed, 21 Nov 2018 12:44:36 +0000
7Subject: [PATCH] arb_texture_view: fix security format warnings
8
9If built with -Werror=format-security then Piglit fails to build:
10
11/tests/spec/arb_texture_view/rendering-layers-image.c:150:8:
12error: format not a string literal and no format arguments [-Werror=format-security]
13 (desc)); \
14 ^~~~~~
15
16In this case test->uniform_type is being turned into a string using snprintf()
17and then passed to piglit_report_subtest_result() which takes a format string,
18but GCC can't verify the format.
19
20As _subtest_report() takes a format string, we can just remove the snprintf()
21and let it construct the label.
22
23Also as X is used once and doesn't make the code clearer, just inline it.
24
25Signed-off-by: Ross Burton <ross.burton@intel.com>
26---
27 tests/spec/arb_texture_view/rendering-layers-image.c | 19 ++++++-------------
28 1 file changed, 6 insertions(+), 13 deletions(-)
29
30diff --git a/tests/spec/arb_texture_view/rendering-layers-image.c b/tests/spec/arb_texture_view/rendering-layers-image.c
31index 415b01657..86148075b 100644
32--- a/tests/spec/arb_texture_view/rendering-layers-image.c
33+++ b/tests/spec/arb_texture_view/rendering-layers-image.c
34@@ -142,26 +142,19 @@ test_render_layers(const struct test_info *test)
35 return pass;
36 }
37
38-#define X(f, desc) \
39- do { \
40- const bool subtest_pass = (f); \
41- piglit_report_subtest_result(subtest_pass \
42- ? PIGLIT_PASS : PIGLIT_FAIL, \
43- (desc)); \
44- pass = pass && subtest_pass; \
45- } while (0)
46-
47 enum piglit_result
48 piglit_display(void)
49 {
50 bool pass = true;
51 for (int test_idx = 0; test_idx < ARRAY_SIZE(tests); test_idx++) {
52 const struct test_info *test = &tests[test_idx];
53- char test_name[128];
54- snprintf(test_name, sizeof(test_name), "layers rendering of %s", test->uniform_type);
55- X(test_render_layers(test), test_name);
56+
57+ const bool subtest_pass = test_render_layers(test);
58+
59+ piglit_report_subtest_result(subtest_pass ? PIGLIT_PASS : PIGLIT_FAIL,
60+ "layers rendering of %s", test->uniform_type);
61+ pass = pass && subtest_pass;
62 }
63-#undef X
64 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
65 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
66 }
67--
682.11.0
69