From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 3C4B63858C83; Fri, 21 Apr 2023 15:11:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C4B63858C83 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: bfd-cvs@sourceware.org Subject: [binutils-gdb] Fix -Wmaybe-uninitialized warning in opcodes/i386-dis.c X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: fbdecfbf285234cd4eba0e7daf480c63b2d65eb3 X-Git-Newrev: da9a978aae78e2c1e35ccdf683474847e4465e5f Message-Id: <20230421151147.3C4B63858C83@sourceware.org> Date: Fri, 21 Apr 2023 15:11:47 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Apr 2023 15:11:47 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dda9a978aae78= e2c1e35ccdf683474847e4465e5f commit da9a978aae78e2c1e35ccdf683474847e4465e5f Author: Tom Tromey Date: Fri Apr 21 07:05:53 2023 -0600 Fix -Wmaybe-uninitialized warning in opcodes/i386-dis.c =20 A recent change in opcodes/i386-dis.c caused a build failure on my x86-64 Fedora 36 system, which uses: =20 $ gcc --version gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4) [...] =20 The error is: =20 ../../binutils-gdb/opcodes/i386-dis.c: In function =E2=80=98OP_J=E2=80= =99: ../../binutils-gdb/opcodes/i386-dis.c:12705:22: error: =E2=80=98val=E2= =80=99 may be used uninitialized [-Werror=3Dmaybe-uninitialized] 12705 | disp =3D val & 0x8000 ? val - 0x10000 : val; | ~~~~^~~~~~~~ =20 This patch fixes the warning. =20 opcodes/ChangeLog 2023-04-21 Tom Tromey =20 * 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 + + * i386-dis.c (OP_J): Check result of get16. + 2023-04-12 Claudiu Zissulescu =20 * 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; =20 - get16 (ins, &val); + if (!get16 (ins, &val)) + return false; disp =3D 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