From: Tom Tromey <tromey@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] Fix -Wmaybe-uninitialized warning in opcodes/i386-dis.c
Date: Fri, 21 Apr 2023 15:11:47 +0000 (GMT) [thread overview]
Message-ID: <20230421151147.3C4B63858C83@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=da9a978aae78e2c1e35ccdf683474847e4465e5f
commit da9a978aae78e2c1e35ccdf683474847e4465e5f
Author: Tom Tromey <tromey@adacore.com>
Date: Fri Apr 21 07:05:53 2023 -0600
Fix -Wmaybe-uninitialized warning in opcodes/i386-dis.c
A recent change in opcodes/i386-dis.c caused a build failure on my
x86-64 Fedora 36 system, which uses:
$ gcc --version
gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)
[...]
The error is:
../../binutils-gdb/opcodes/i386-dis.c: In function ‘OP_J’:
../../binutils-gdb/opcodes/i386-dis.c:12705:22: error: ‘val’ may be used uninitialized [-Werror=maybe-uninitialized]
12705 | disp = val & 0x8000 ? val - 0x10000 : val;
| ~~~~^~~~~~~~
This patch fixes the warning.
opcodes/ChangeLog
2023-04-21 Tom Tromey <tromey@adacore.com>
* i386-dis.c (OP_J): Check result of get16.
Diff:
---
opcodes/ChangeLog | 4 ++++
opcodes/i386-dis.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index d0c338a0f6d..890931e6b8a 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,7 @@
+2023-04-21 Tom Tromey <tromey@adacore.com>
+
+ * i386-dis.c (OP_J): Check result of get16.
+
2023-04-12 Claudiu Zissulescu <claziss@synopsys.com>
* arc-tbl.h: Remove vadds2, vadds2h, vadds4h, vaddsubs,
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 46ba01fe093..f021bdaa3e7 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -12701,7 +12701,8 @@ OP_J (instr_info *ins, int bytemode, int sizeflag)
{
int val;
- get16 (ins, &val);
+ if (!get16 (ins, &val))
+ return false;
disp = val & 0x8000 ? val - 0x10000 : val;
/* In 16bit mode, address is wrapped around at 64k within
the same segment. Otherwise, a data16 prefix on a jump
reply other threads:[~2023-04-21 15:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230421151147.3C4B63858C83@sourceware.org \
--to=tromey@sourceware.org \
--cc=bfd-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).