From 8e196214a0c3d90ed8c4fe53a9cf308402274d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Mon, 6 Nov 2023 14:22:32 +0100 Subject: [PATCH] mesa: Use a switch for state_iter and be more precise about its type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even if this technically won't change anything, it prevents a false-positive of uninitialized use of variables with clang. Signed-off-by: Corentin Noël Reviewed-by: Erik Faye-Lund Part-of: --- src/mesa/program/prog_statevars.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index 62d8a23d20d..cd6cafe6d49 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -1617,22 +1617,28 @@ _mesa_optimize_state_parameters(struct gl_constants *consts, gl_state_index16 state = STATE_NOT_STATE_VAR; unsigned num_lights = 0; - for (unsigned state_iter = STATE_LIGHTPROD_ARRAY_FRONT; + for (gl_state_index state_iter = STATE_LIGHTPROD_ARRAY_FRONT; state_iter <= STATE_LIGHTPROD_ARRAY_TWOSIDE; state_iter++) { unsigned num_attribs, base_attrib, attrib_incr; - if (state_iter == STATE_LIGHTPROD_ARRAY_FRONT) { + switch (state_iter) { + case STATE_LIGHTPROD_ARRAY_FRONT: num_attribs = 3; base_attrib = MAT_ATTRIB_FRONT_AMBIENT; attrib_incr = 2; - } else if (state_iter == STATE_LIGHTPROD_ARRAY_BACK) { + break; + case STATE_LIGHTPROD_ARRAY_BACK: num_attribs = 3; base_attrib = MAT_ATTRIB_BACK_AMBIENT; attrib_incr = 2; - } else if (state_iter == STATE_LIGHTPROD_ARRAY_TWOSIDE) { + break; + case STATE_LIGHTPROD_ARRAY_TWOSIDE: num_attribs = 6; base_attrib = MAT_ATTRIB_FRONT_AMBIENT; attrib_incr = 1; + break; + default: + unreachable("unexpected state-var"); } /* Find all attributes for one light. */