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

Mike Frysinger via Gdb-patches
2022-10-24T17:14:21Z

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

On 24 Oct 2022 16:57, Andrew Burgess wrote:
> Mike Frysinger <vapier@gentoo.org> writes:
> commit 79f4f1d82d1da482e223079deb453eda7b2d2323
> Author: Andrew Burgess <aburgess@redhat.com>
> Date: Mon Oct 24 16:55:07 2022 +0100
>
> sim/cgen: initialize variable at creation in engine_run_n
>
> Zero initialize engine_fns entirely at creation, then override those
> fields we intend to use, rather than zero just initializing the unused
> fields later on.
>
> There should be no user visible changes after this commit.
>
> diff --git a/sim/common/cgen-run.c b/sim/common/cgen-run.c
> index a9a493c01b9..1ace067a395 100644
> --- a/sim/common/cgen-run.c
> +++ b/sim/common/cgen-run.c
> @@ -229,7 +229,7 @@ static void
> engine_run_n (SIM_DESC sd, int next_cpu_nr, int nr_cpus, int max_insns, int fast_p)
> {
> int i;
> - ENGINE_FN *engine_fns[MAX_NR_PROCESSORS];
> + ENGINE_FN *engine_fns[MAX_NR_PROCESSORS] = {};
>
> SIM_ASSERT (nr_cpus <= MAX_NR_PROCESSORS);
> SIM_ASSERT (next_cpu_nr >= 0 && next_cpu_nr < nr_cpus);
> @@ -242,11 +242,6 @@ 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. */

this comment is useful, so i would retain it

otherwise lgtm
-mike

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