Message ID | c397f9132c484071c54fc01aa7dd8c1d5fe06490.1666258361.git.research_trasio@irq.a4lg.com |
---|---|
State | Committed |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BF498395B46C for <patchwork@sourceware.org>; Thu, 20 Oct 2022 09:40:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF498395B46C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666258835; bh=9yaiREs4hr+8MWXAgIaar2Q8T/GS3dNAAD3l3KlEt6M=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=n5EvTpWCursHBh4WVCHDGWWtcErIukt+rs9+1O7s9igdnprnAdQ9xy8e3qp6zd0dU ii0cqQAulGPOgRMygbqkaPSMqrefWIcZ0ZIdN8k0hTfGKfYbQ4zeZCTl9p49DYDQe7 9VpoE7i9n+YdUWMVuPdye5bXOdKywXaX7v54o9i4= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id B81E938EA2E1 for <gdb-patches@sourceware.org>; Thu, 20 Oct 2022 09:39:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B81E938EA2E1 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 15BE8300089; Thu, 20 Oct 2022 09:39:02 +0000 (UTC) To: Tsukasa OI <research_trasio@irq.a4lg.com>, Andrew Burgess <aburgess@redhat.com>, Mike Frysinger <vapier@gentoo.org>, Nick Clifton <nickc@redhat.com> Subject: [PATCH 35/40] sim/sh: Initialize some variables Date: Thu, 20 Oct 2022 09:32:40 +0000 Message-Id: <c397f9132c484071c54fc01aa7dd8c1d5fe06490.1666258361.git.research_trasio@irq.a4lg.com> In-Reply-To: <cover.1666258361.git.research_trasio@irq.a4lg.com> References: <cover.1666258361.git.research_trasio@irq.a4lg.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Tsukasa OI via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Tsukasa OI <research_trasio@irq.a4lg.com> Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
sim+gdb: Suppress warnings if built with Clang (big batch 1)
|
|
Commit Message
Tsukasa OI
Oct. 20, 2022, 9:32 a.m. UTC
Clang generates a warning if a variable may be used uninitialized on some cases ("-Wsometimes-uninitialized"). On the default configuration, it causes a build failure (unless "--disable-werror" is specified). The cause of this error, $(builddir)/sim/sh/ppi.c is generated from $(srcdir)/sim/sh/gencode.c. Clang will detect the variable res may be used uninitialized when used on some cases. Likewise, GCC generates a warning if a variable may be used uninitialized on some cases ("-Wmaybe-uninitialized"). GCC will detect variables res, res_grd, carry, overflow and greater_equal may be used uninitialized on some cases. Despite that GCC will not cause a build failure even when "--enable-werror" is specified, it would be better to fix this as well since the cause is in the same function. --- sim/sh/gencode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 20 Oct 2022 09:32, Tsukasa OI wrote: > Clang generates a warning if a variable may be used uninitialized on some > cases ("-Wsometimes-uninitialized"). On the default configuration, it > causes a build failure (unless "--disable-werror" is specified). > > The cause of this error, $(builddir)/sim/sh/ppi.c is generated from > $(srcdir)/sim/sh/gencode.c. Clang will detect the variable res may be used > uninitialized when used on some cases. > > Likewise, GCC generates a warning if a variable may be used uninitialized > on some cases ("-Wmaybe-uninitialized"). > > GCC will detect variables res, res_grd, carry, overflow and greater_equal > may be used uninitialized on some cases. Despite that GCC will not cause a > build failure even when "--enable-werror" is specified, it would be better > to fix this as well since the cause is in the same function. > --- > sim/sh/gencode.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > --- a/sim/sh/gencode.c > +++ b/sim/sh/gencode.c > @@ -3257,8 +3257,8 @@ ppi_gensim (void) > printf (" static char const u_tab[] = { 8, 10, 7, 5};\n"); > printf ("\n"); > printf (" int z;\n"); > - printf (" int res, res_grd;\n"); > - printf (" int carry, overflow, greater_equal;\n"); > + printf (" int res = 0, res_grd = 0;\n"); > + printf (" int carry = 0, overflow = 0, greater_equal = 0;\n"); i've left this warning in because i don't know what the right answer is, and i'm not inclined to dig into the ISA to find out. simply initializing the variables to 0 might mean we're masking real bugs where we should be loading the state from the current CPU registers instead. -mike
diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c index 5eb7caf2589..03979695b08 100644 --- a/sim/sh/gencode.c +++ b/sim/sh/gencode.c @@ -3257,8 +3257,8 @@ ppi_gensim (void) printf (" static char const u_tab[] = { 8, 10, 7, 5};\n"); printf ("\n"); printf (" int z;\n"); - printf (" int res, res_grd;\n"); - printf (" int carry, overflow, greater_equal;\n"); + printf (" int res = 0, res_grd = 0;\n"); + printf (" int carry = 0, overflow = 0, greater_equal = 0;\n"); printf ("\n"); printf (" switch (ppi_table[iword >> 4]) {\n");