From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 41AD5385153A for ; Thu, 27 Oct 2022 15:53:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 41AD5385153A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666886024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=43eI5f77UsV0ADEGC5kgHVsZd3pYzTtjdQ2yoLS+ZYI=; b=Ofyw0IT/Lnz0OElvutmI8lED5IgBqM1JUM9UC/1cPvzlAXZST3eTzxHT0qbBTSZ6SI42// Ivbq1huUjaqIu1dnI16N1OD+H1KRq1dzbsGAdkHotUZeTJuqbPjtIqslDkrdMPnY4af+HA +ePww/SyBX7yv8y6Q+u6qclmW6YNBZg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-185-AymPsh-9NumsHUi5aUPSbw-1; Thu, 27 Oct 2022 11:53:43 -0400 X-MC-Unique: AymPsh-9NumsHUi5aUPSbw-1 Received: by mail-wr1-f71.google.com with SMTP id r22-20020adfa156000000b0023660e969ddso574302wrr.19 for ; Thu, 27 Oct 2022 08:53:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=43eI5f77UsV0ADEGC5kgHVsZd3pYzTtjdQ2yoLS+ZYI=; b=16HAXKMCtrPTrGYTnikuOsI9c3DQVXcxz0Tq7Adk5wJqY8RFs4XGt4GJUNv1PjkT0q EKgjP2m2cRWsrZwLHCHQ86R5ea0QNBOrAmBl0/2tL0KLtuzj79oKWCY5QrFHiBPeE+qr i5WPyejKvNyALfypYb0egXC3RUIF+A32h5GTlIuoaNHKMlvXqmcBcmyxEZGhYgc4RksF tOJlx3U4kcqdQSbj2W2pgV4OCWIckXRwZbOa3GSaBsjS7tl5UvtMQYeYMRp84dULzt6/ I5DNKkLV9ULkj1XXII3XUcdg6ZDxAGAtw97ZuwlG25c18vCp5Et0l18Ko/fz/4CIAA8z VCvQ== X-Gm-Message-State: ACrzQf0VUfuQrdmI82/oc8vAUt7axs6QZDMjP6yBekh8ny5LEAWOLfeK uAhHnASqkES3xZRNPuqhpd1jOt1qOvo7l99mx3kgoKHtg3UBCFfQes9bngb5u/Qhfp3PFlq5XpV JPjoTblA7TOseRRgon3xdhg== X-Received: by 2002:adf:e804:0:b0:236:657e:756e with SMTP id o4-20020adfe804000000b00236657e756emr17720625wrm.452.1666886021772; Thu, 27 Oct 2022 08:53:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Uw14mSaSKFfST/kq9R/hZKZhJj4+sWC5q2kyQRUJSYgwFTFY5FwRUwxlqIGvx+cp6YFzPZg== X-Received: by 2002:adf:e804:0:b0:236:657e:756e with SMTP id o4-20020adfe804000000b00236657e756emr17720616wrm.452.1666886021553; Thu, 27 Oct 2022 08:53:41 -0700 (PDT) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id iw16-20020a05600c54d000b003c6237e867esm2086784wmb.0.2022.10.27.08.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 08:53:41 -0700 (PDT) From: Andrew Burgess To: Mike Frysinger Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/5] sim/cgen: mask uninitialized variable warning in cgen-run.c In-Reply-To: References: <87o7u18b9i.fsf@redhat.com> Date: Thu, 27 Oct 2022 16:53:39 +0100 Message-ID: <87bkpx5kl8.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Mike Frysinger writes: > On 24 Oct 2022 16:57, Andrew Burgess wrote: >> Mike Frysinger writes: >> commit 79f4f1d82d1da482e223079deb453eda7b2d2323 >> Author: Andrew Burgess >> 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 I added a variant of this comment back, and pushed this patch. Thanks, Andrew --- commit a09f33be653fb112586be126f3d5ab848aaed095 Author: Andrew Burgess 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..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);