From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iAz4MRW2VmPRHhAAWB0awg (envelope-from ) for ; Mon, 24 Oct 2022 11:58:13 -0400 Received: by simark.ca (Postfix, from userid 112) id BE2811E112; Mon, 24 Oct 2022 11:58:13 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Zl7fxhbn; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 737711E0D3 for ; Mon, 24 Oct 2022 11:58:13 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB2BB3858022 for ; Mon, 24 Oct 2022 15:58:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB2BB3858022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666627092; bh=ql4MYWUTcFW8hWqsGG9n6Tk2PkaA3nbX8qzlTxk4dMM=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Zl7fxhbn4XzUovsAlmwTgxffXifyltqWitHqtsWFUUNpzY7Mg9wxZSoa2OTy9UxOF qDaXMspWTfO/HMz/76s9+q/kqg4xTipdFP+qFdbSj1JQKdZU6GUQh4TA/gtEfvqoIW 4PD7XTGw7/E7V0cpPfRMp69HHNofbaAb4dZN47ww= 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 130F0385840C for ; Mon, 24 Oct 2022 15:57:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 130F0385840C Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-121-iPbRPTcbPGevlaLUH1K3sQ-1; Mon, 24 Oct 2022 11:57:48 -0400 X-MC-Unique: iPbRPTcbPGevlaLUH1K3sQ-1 Received: by mail-qk1-f197.google.com with SMTP id i11-20020a05620a404b00b006eeb0791c1aso9356955qko.10 for ; Mon, 24 Oct 2022 08:57:48 -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=ql4MYWUTcFW8hWqsGG9n6Tk2PkaA3nbX8qzlTxk4dMM=; b=t6PM9YBk1tTHF7qGOB/lYyj7aJuuSawcdYGanTqJv/VG7vrOMPw7fvSPsIsERNLs12 UoyaLPPUQF9dpC/Fy/I9N+ycv7B/skBUvHNuOXQi8hcVCVXjznnTz+nEUh37XmAE1nGn DyiLUTZuCfcZ6xegFSmmqIjvjFjIamd2swT8ZrMM1eEuuHk1HxgeAQGW8kYSDgXtY/2y utuzOVL/jOrQcpgQ1JBBZAeSrZz6qrPZIIDq37X8RtaKIqHq5WKjnDVeEiQemBPzou1k xDdINTApwac7aMAoJtGMYyUODiKN4BuFtGk1uHyKtNnPqSw8QYsC1IeIpE5uLbrM+Q1u iV1Q== X-Gm-Message-State: ACrzQf2t3gNuNDZwPTfy+yD028CznCvNsBAbF+g1rPhpYuNx4Z8VfHIv HNBe4h37BsMevQPwfPXpOmC5fJDgbL6bccBMOqCb/l42Fj9YKGaaQjXboWpLjjU8c5FOA1MHZIs s9XzLr52GVGOyX0z4oNpd3A== X-Received: by 2002:ac8:5747:0:b0:39d:cc25:a844 with SMTP id 7-20020ac85747000000b0039dcc25a844mr14709917qtx.342.1666627067910; Mon, 24 Oct 2022 08:57:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Sbil8gw1mu5xtDbRfplfXBpvCSE9cdoeRKoDO82yHQBKdIwwVE0EjoKbCgWCYbEbN5yfizQ== X-Received: by 2002:ac8:5747:0:b0:39d:cc25:a844 with SMTP id 7-20020ac85747000000b0039dcc25a844mr14709907qtx.342.1666627067661; Mon, 24 Oct 2022 08:57:47 -0700 (PDT) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id f8-20020ac84708000000b0039c9d0dcaf8sm106496qtp.85.2022.10.24.08.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 08:57:47 -0700 (PDT) To: Mike Frysinger Subject: Re: [PATCH 1/5] sim/cgen: mask uninitialized variable warning in cgen-run.c In-Reply-To: References: Date: Mon, 24 Oct 2022 16:57:45 +0100 Message-ID: <87o7u18b9i.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Mike Frysinger writes: > 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] = {}; How's the patch below? Thanks, Andrew --- 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. */ - for (i = nr_cpus; i < MAX_NR_PROCESSORS; ++i) - engine_fns[i] = NULL; - while (1) { SIM_ENGINE_PREFIX_HOOK (sd);