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 130F0385840C for ; Mon, 24 Oct 2022 15:57:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 130F0385840C 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=1666627071; 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=ql4MYWUTcFW8hWqsGG9n6Tk2PkaA3nbX8qzlTxk4dMM=; b=UZ6endjIXxTdqOs1NG6aT0vYoEaWBY7Xx+kTF80sg1Od0n6P069wCeYI7e9hXN6gZNcZ7U dwV3KRnebo/do1KSYWZyslQOjrcUt7Aie0Tg/1v25qX4A6opYZB4Y48VOAKK4CYiuPXPFs Kttkaf00p3rc5Ms8thD0gMuc+gY5daw= 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) 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: 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-Spam-Status: No, score=-11.8 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 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);