freedreno: a2xx: fix maybe uninitialized variable

Detected when working on adding support for Undefined Behaviour
Sanitizer, this fixes:

```
../src/gallium/drivers/freedreno/a2xx/ir2_nir.c: In function 'load_const':
../src/gallium/drivers/freedreno/a2xx/ir2_nir.c:154:24: error: 'swiz' may be used uninitialized [-Werror=maybe-uninitialized]
  154 |    unsigned imm_ncomp, swiz, idx, i, j;
      |                        ^~~~
../src/gallium/drivers/freedreno/a2xx/ir2_nir.c:195:30: error: 'imm_ncomp' may be used uninitialized [-Werror=maybe-uninitialized]
  195 |    so->immediates[idx].ncomp = imm_ncomp;
      |    ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
../src/gallium/drivers/freedreno/a2xx/ir2_nir.c:154:13: note: 'imm_ncomp' was declared here
  154 |    unsigned imm_ncomp, swiz, idx, i, j;
      |             ^~~~~~~~~
cc1: all warnings being treated as errors
```

Reviewed-by: Rob Clark <robclark@freedesktop.org>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30880>
This commit is contained in:
Juan A. Suarez Romero
2024-08-27 17:28:22 +02:00
committed by Marge Bot
parent dab7b23d3a
commit 9d6c667151

View File

@@ -134,7 +134,9 @@ static struct ir2_src
load_const(struct ir2_context *ctx, float *value_f, unsigned ncomp)
{
struct fd2_shader_stateobj *so = ctx->so;
unsigned imm_ncomp, swiz, idx, i, j;
unsigned idx, i, j;
unsigned imm_ncomp = 0;
unsigned swiz = 0;
uint32_t *value = (uint32_t *)value_f;
/* try to merge with existing immediate (TODO: try with neg) */