diff options
author | Tom de Vries <tdevries@suse.de> | 2023-11-13 09:31:20 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-11-13 09:31:20 +0100 |
commit | 6b682bbf86f37982ce1d270fb47f363413490bda (patch) | |
tree | 10141f97016d2c71c46df045162f597ffefef1e8 /gdb/tui | |
parent | aba9fa5f4be8c27e07c5330957fff17e4160920b (diff) | |
download | gdb-6b682bbf86f37982ce1d270fb47f363413490bda.zip gdb-6b682bbf86f37982ce1d270fb47f363413490bda.tar.gz gdb-6b682bbf86f37982ce1d270fb47f363413490bda.tar.bz2 |
[gdb/tui] Fix Wmaybe-uninitialized in tui_find_disassembly_address
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.
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-disasm.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index 9965ae1..dcafbfb 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 { |