From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id EAF323851526; Thu, 27 Oct 2022 15:52:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAF323851526 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666885960; bh=gPb3hT4Yd2HH//oiRjHcshUztVo797ljIJF4uyolyq4=; h=From:To:Subject:Date:From; b=hd/RN1c60+Mx7dUQLMgwZ5MpakfFXqkQXlxlR5u6sgxcuwwTdMi8wyrxSYIxcacTC WTwG4n+5Y0wtGylIxbEjjNo4bB8ZoGXcKkQIg4kqkAceANajnOXiEfGW+ONiLWkrhB 9Kh9fYBVpNKw3w13y93lFQ3AOzCrFcBQXdKY7oOY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] sim/cgen: initialize variable at creation in engine_run_n X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 48ca5676924d2609f1b9ea1990719c9eb41e88a2 X-Git-Newrev: a09f33be653fb112586be126f3d5ab848aaed095 Message-Id: <20221027155240.EAF323851526@sourceware.org> Date: Thu, 27 Oct 2022 15:52:40 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Da09f33be653f= b112586be126f3d5ab848aaed095 commit a09f33be653fb112586be126f3d5ab848aaed095 Author: Andrew Burgess Date: Mon Oct 24 16:55:07 2022 +0100 sim/cgen: initialize variable at creation in engine_run_n =20 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. =20 There should be no user visible changes after this commit. Diff: --- sim/common/cgen-run.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sim/common/cgen-run.c b/sim/common/cgen-run.c index a9a493c01b9..b6400a69c13 100644 --- a/sim/common/cgen-run.c +++ b/sim/common/cgen-run.c @@ -229,7 +229,9 @@ static void engine_run_n (SIM_DESC sd, int next_cpu_nr, int nr_cpus, int max_insns, in= t fast_p) { int i; - ENGINE_FN *engine_fns[MAX_NR_PROCESSORS]; + /* Ensure that engine_fns is fully initialized, this silences a compiler + warning when engine_fns is used below. */ + ENGINE_FN *engine_fns[MAX_NR_PROCESSORS] =3D {}; =20 SIM_ASSERT (nr_cpus <=3D MAX_NR_PROCESSORS); SIM_ASSERT (next_cpu_nr >=3D 0 && next_cpu_nr < nr_cpus); @@ -242,11 +244,6 @@ engine_run_n (SIM_DESC sd, int next_cpu_nr, int nr_cpu= s, int max_insns, int fast prime_cpu (cpu, max_insns); } =20 - /* Ensure the remaining engine_fns slots are initialized, this silences a - compiler warning when engine_fns is used below. */ - for (i =3D nr_cpus; i < MAX_NR_PROCESSORS; ++i) - engine_fns[i] =3D NULL; - while (1) { SIM_ENGINE_PREFIX_HOOK (sd);