From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id AF83E3857C4F for ; Fri, 29 Sep 2023 10:07:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF83E3857C4F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E7BC91F895 for ; Fri, 29 Sep 2023 10:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1695982041; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xy5MIfOpkmivbz8Xr794lYjHLMxSMrbVJP+rdh95UTI=; b=v1NpFylQnoJCaB2l7OVepixtx5hHhKDJMzE/WKqb8UGaTUnCxazI78XA7t+FL1CrreGmcK dPwy9L18twbc9XtOUGkJEnt+2P1nSuATyTCqo9jkTazZ7bxBjvDxUxJt4CemUouW+plo78 hPgvNveWTMENsHvQpELkSNtcIaqdWZg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1695982041; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xy5MIfOpkmivbz8Xr794lYjHLMxSMrbVJP+rdh95UTI=; b=d6+mGCoYRFoFIQ9ak1PTGqqFmrP1OEVhe7KgOGYG5/DMygQGkj4aMa68wXKY2ZyxMwj34D H8GI4AmQeN97huCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CB3E91390A for ; Fri, 29 Sep 2023 10:07:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cGiIMNmhFmU5HQAAMHmgww (envelope-from ) for ; Fri, 29 Sep 2023 10:07:21 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 2/2] [gdb/tui] Fix Wmaybe-uninitialized in tui_find_disassembly_address Date: Fri, 29 Sep 2023 12:07:28 +0200 Message-Id: <20230929100728.27029-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230929100728.27029-1-tdevries@suse.de> References: <20230929100728.27029-1-tdevries@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: When building gdb with -O2, we run into: ... gdb/tui/tui-disasm.c: In function ‘CORE_ADDR tui_find_disassembly_address \ (gdbarch*, CORE_ADDR, int)’: gdb/tui/tui-disasm.c:293:7: warning: ‘last_addr’ may be used uninitialized \ in this function [-Wmaybe-uninitialized] if (last_addr < pc) ^~ ... The warning triggers since commit 72535eb14bd ("[gdb/tui] Fix segfault in tui_find_disassembly_address"). Fix the warning by ensuring that last_addr is initialized at the point of use: ... + last_addr = asm_lines.back ().addr; if (last_addr < pc) ... Tested on x86_64-linux. --- gdb/tui/tui-disasm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index e6d4ee6a7ef..7e953b72ab7 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -278,7 +278,6 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) /* Take the best possible match we have. */ new_low = *possible_new_low; next_addr = tui_disassemble (gdbarch, asm_lines, new_low, max_lines); - last_addr = asm_lines.back ().addr; } /* The following walk forward assumes that ASM_LINES contains exactly @@ -290,6 +289,7 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) We keep the disassembled instructions in the 'lines' window and shift it downward (increasing its addresses). */ int pos = max_lines - 1; + last_addr = asm_lines.back ().addr; if (last_addr < pc) do { -- 2.35.3