From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id CF4DC385702D for ; Fri, 28 Oct 2022 06:53:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CF4DC385702D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=irq.a4lg.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=irq.a4lg.com Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 6935B300089; Fri, 28 Oct 2022 06:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1666939988; bh=Auh0nWenFFAoGBm2khp0ftbBkMMln1UMhVz+gswOmZI=; h=From:To:Cc:Subject:Date:Message-Id:Mime-Version:Content-Type: Content-Transfer-Encoding; b=K67YsurFD382NTGvqXPsV8sikxJd/qj/6xMnwTQ5Jf1AYel0wGjCQbhD9l3UVlJ4t aJ4NR7cYhkAEm4hmHz6EOHcQD3IaN8camnhHgu9VPkvnw1ZmP+/Ai/5IielZujziKf kuPebQIy5cnBMW8W42dz3+7iRbK50Iu6U5NQJxrQ= From: Tsukasa OI To: Tsukasa OI , Nelson Chu , Kito Cheng , Palmer Dabbelt Cc: binutils@sourceware.org Subject: [PATCH] RISC-V: Fix build failure for -Werror=maybe-uninitialized Date: Fri, 28 Oct 2022 06:53:02 +0000 Message-Id: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 List-Id: Commit 40f1a1a4564b ("RISC-V: Output mapping symbols with ISA string.") caused a build failure on GCC 12 as follows: make[3]: Entering directory '$(builddir)/gas' CC config/tc-riscv.o In file included from $(srcdir)/gas/config/tc-riscv.c:23: $(srcdir)/gas/as.h: In function ‘make_mapping_symbol’: $(srcdir)/gas/as.h:123:15: error: ‘buff’ may be used uninitialized [-Werror=maybe-uninitialized] 123 | #define xfree free | ^~~~ $(srcdir)/gas/config/tc-riscv.c:487:9: note: ‘buff’ was declared here 487 | char *buff; | ^~~~ cc1: all warnings being treated as errors make[3]: *** [Makefile:1425: config/tc-riscv.o] Error 1 This is caused by a false positive of "maybe uninitialized" variable detection (-Wmaybe-uninitialized). To avoid this error, this commit initializes the local variable buff to NULL first in all cases. gas/ChangeLog: * config/tc-riscv.c (make_mapping_symbol): Initialize variable buff with NULL to avoid build failure caused by a GCC's false positive of maybe uninitialized variable detection. --- gas/config/tc-riscv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 91cff7de604..f4478eac11e 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -484,7 +484,7 @@ make_mapping_symbol (enum riscv_seg_mstate state, bool reset_seg_arch_str) { const char *name; - char *buff; + char *buff = NULL; switch (state) { case MAP_DATA: base-commit: 56d4450bdfc873ff3c2d1ebb194c7a076d4d13f6 -- 2.37.2