[i-g-t 2/2] tests/chamelium/kms_color_chamelium: Use "const" for immutable data

Bhanuprakash Modem bhanuprakash.modem at intel.com
Thu Oct 6 04:53:53 UTC 2022


CTM test is mutating expected_colors, which was passed all the
way from the top and really should be const and have a local
thing to mutate.

Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
Cc: Kunal Joshi <kunal1.joshi at intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
 tests/chamelium/kms_color_chamelium.c | 37 ++++++++++++++-------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/tests/chamelium/kms_color_chamelium.c b/tests/chamelium/kms_color_chamelium.c
index 792aef8a..7c9b5bfc 100644
--- a/tests/chamelium/kms_color_chamelium.c
+++ b/tests/chamelium/kms_color_chamelium.c
@@ -210,9 +210,9 @@ static bool test_pipe_gamma(data_t *data,
  */
 static bool test_pipe_ctm(data_t *data,
 			  igt_plane_t *primary,
-			  color_t *before,
-			  color_t *after,
-			  double *ctm_matrix,
+			  const color_t *before,
+			  const color_t *after,
+			  const double *ctm_matrix,
 			  struct chamelium_port *port)
 {
 	gamma_lut_t *degamma_linear, *gamma_linear;
@@ -464,9 +464,9 @@ run_gamma_degamma_tests_for_pipe(data_t *data, enum pipe p,
 
 static void
 run_ctm_tests_for_pipe(data_t *data, enum pipe p,
-		       color_t *expected_colors,
-		       double *ctm,
-		       int iter)
+		       const color_t *expected_colors,
+		       const double *ctm,
+		       const int iterator)
 {
 	double delta;
 	color_t red_green_blue[] = {
@@ -494,10 +494,11 @@ run_ctm_tests_for_pipe(data_t *data, enum pipe p,
 	data->mode = igt_output_get_mode(data->output);
 
 	igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(p), data->output->name) {
+		color_t expected[3];
 		bool success = false;
 		int i;
 
-		if (!iter)
+		if (!iterator)
 			success = test_pipe_ctm(data, data->primary,
 						red_green_blue,
 						expected_colors, ctm,
@@ -509,13 +510,13 @@ run_ctm_tests_for_pipe(data_t *data, enum pipe p,
 		 * get clamped or rounded values and we also need to account
 		 * for odd number of items in the LUTs.
 		 */
-		for (i = 0; i < iter; i++) {
-			expected_colors[0].r =
-				expected_colors[1].g =
-				expected_colors[2].b =
-				ctm[0] + delta * (i - (iter / 2));
-			if (test_pipe_ctm(data, data->primary,
-					  red_green_blue, expected_colors,
+		for (i = 0; i < iterator; i++) {
+			expected[0].r =
+			expected[1].g =
+			expected[2].b =
+				ctm[0] + delta * (i - (iterator / 2));
+			if (test_pipe_ctm(data, data->primary, red_green_blue,
+					  (const color_t *) expected,
 					  ctm, data->ports[port_idx])) {
 				success = true;
 				break;
@@ -559,9 +560,9 @@ run_tests_for_pipe(data_t *data)
 	};
 	struct {
 		const char *name;
-		int iter;
-		color_t colors[3];
-		double ctm[9];
+		const int iterator;
+		const color_t colors[3];
+		const double ctm[9];
 		const char *desc;
 	} ctm_tests[] = {
 		{ "ctm-red-to-blue", 0,
@@ -650,7 +651,7 @@ run_tests_for_pipe(data_t *data)
 				run_ctm_tests_for_pipe(data, pipe,
 						       ctm_tests[i].colors,
 						       ctm_tests[i].ctm,
-						       ctm_tests[i].iter);
+						       ctm_tests[i].iterator);
 			}
 		}
 	}
-- 
2.37.3



More information about the Intel-gfx-trybot mailing list