public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] sim/cgen: initialize variable at creation in engine_run_n
Date: Thu, 27 Oct 2022 15:52:40 +0000 (GMT)	[thread overview]
Message-ID: <20221027155240.EAF323851526@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a09f33be653fb112586be126f3d5ab848aaed095

commit a09f33be653fb112586be126f3d5ab848aaed095
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:
---
 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, int 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] = {};
 
   SIM_ASSERT (nr_cpus <= MAX_NR_PROCESSORS);
   SIM_ASSERT (next_cpu_nr >= 0 && next_cpu_nr < nr_cpus);
@@ -242,11 +244,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.  */
-  for (i = nr_cpus; i < MAX_NR_PROCESSORS; ++i)
-    engine_fns[i] = NULL;
-
   while (1)
     {
       SIM_ENGINE_PREFIX_HOOK (sd);

                 reply	other threads:[~2022-10-27 15:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221027155240.EAF323851526@sourceware.org \
    --to=aburgess@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).