Re: [PATCH 1/5] sim/cgen: mask uninitialized variable warning in cgen-run.c

Mike Frysinger via Gdb-patches
2022-10-23T13:45:45Z

[-- Attachment #1: Type: text/plain, Size: 698 bytes --]

On 12 Oct 2022 13:38, Andrew Burgess via Gdb-patches wrote:
> --- a/sim/common/cgen-run.c
> +++ b/sim/common/cgen-run.c
> @@ -242,6 +242,11 @@ engine_run_n (SIM_DESC sd, int next_cpu_nr, int nr_cpus, int max_insns, int fast
> prime_cpu (cpu, max_insns);
> }
>
> + /* Ensure the remaining engine_fns slots are initialized, this silences a
> + compiler warning when engine_fns is used below. */
> + for (i = nr_cpus; i < MAX_NR_PROCESSORS; ++i)
> + engine_fns[i] = NULL;

engine_fns is declared in this func. why not assign it and let gcc handle
the rest ?
- ENGINE_FN *engine_fns[MAX_NR_PROCESSORS];
+ ENGINE_FN *engine_fns[MAX_NR_PROCESSORS] = {};
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]