From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id ED4883858C62; Mon, 24 Apr 2023 11:33:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED4883858C62 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org Subject: [binutils-gdb] gcc-13 i386-dis.c warning X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: 2043ddb2185096eadc111865f31a70d1cffd6f4c X-Git-Newrev: 5b720e50c7a3c125b7626c8bb64d7234fc7fb317 Message-Id: <20230424113314.ED4883858C62@sourceware.org> Date: Mon, 24 Apr 2023 11:33:14 +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: Mon, 24 Apr 2023 11:33:15 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5b720e50c7a3= c125b7626c8bb64d7234fc7fb317 commit 5b720e50c7a3c125b7626c8bb64d7234fc7fb317 Author: Alan Modra Date: Mon Apr 24 13:27:46 2023 +0930 gcc-13 i386-dis.c warning =20 opcodes/i386-dis.c: In function =E2=80=98print_insn=E2=80=99: opcodes/i386-dis.c:9865:22: error: storing the address of local variable =E2=80=98priv=E2=80=99 in =E2=80=98*info.private_data=E2=80=99= [-Werror=3Ddangling-pointer=3D] =20 * i386-dis.c (print_insn): Clear info->private_data before returning. Diff: --- opcodes/i386-dis.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index fc0515cd2b0..1fe54289655 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -9737,6 +9737,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int i= ntel_syntax) { const struct dis386 *dp; int i; + int ret; char *op_txt[MAX_OPERANDS]; int needcomma; bool intel_swap_2_3; @@ -9893,16 +9894,21 @@ print_insn (bfd_vma pc, disassemble_info *info, int= intel_syntax) i386_dis_printf (&ins, dis_style_mnemonic, "%s%s", (i =3D=3D 0 ? "" : " "), prefix_name (&ins, ins.all_prefixes[i], sizeflag)); - return i; + ret =3D i; + goto out; =20 case ckp_fetch_error: - return fetch_error (&ins); + goto fetch_error_out; } =20 ins.insn_codep =3D ins.codep; =20 if (!fetch_code (info, ins.codep + 1)) - return fetch_error (&ins); + { + fetch_error_out: + ret =3D fetch_error (&ins); + goto out; + } =20 ins.two_source_ops =3D (*ins.codep =3D=3D 0x62) || (*ins.codep =3D=3D 0x= c8); =20 @@ -9915,7 +9921,8 @@ print_insn (bfd_vma pc, disassemble_info *info, int i= ntel_syntax) i386_dis_printf (&ins, dis_style_mnemonic, "%s ", prefix_name (&ins, ins.all_prefixes[i], sizeflag)); i386_dis_printf (&ins, dis_style_mnemonic, "fwait"); - return i + 1; + ret =3D i + 1; + goto out; } =20 if (*ins.codep =3D=3D 0x0f) @@ -9924,7 +9931,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int i= ntel_syntax) =20 ins.codep++; if (!fetch_code (info, ins.codep + 1)) - return fetch_error (&ins); + goto fetch_error_out; threebyte =3D *ins.codep; dp =3D &dis386_twobyte[threebyte]; ins.need_modrm =3D twobyte_has_modrm[threebyte]; @@ -9948,30 +9955,30 @@ print_insn (bfd_vma pc, disassemble_info *info, int= intel_syntax) =20 ins.end_codep =3D ins.codep; if (ins.need_modrm && !fetch_modrm (&ins)) - return fetch_error (&ins); + goto fetch_error_out; =20 if (dp->name =3D=3D NULL && dp->op[0].bytemode =3D=3D FLOATCODE) { if (!get_sib (&ins, sizeflag) || !dofloat (&ins, sizeflag)) - return fetch_error (&ins); + goto fetch_error_out; } else { dp =3D get_valid_dis386 (dp, &ins); if (dp =3D=3D &err_opcode) - return fetch_error (&ins); + goto fetch_error_out; if (dp !=3D NULL && putop (&ins, dp->name, sizeflag) =3D=3D 0) { if (!get_sib (&ins, sizeflag)) - return fetch_error (&ins); + goto fetch_error_out; for (i =3D 0; i < MAX_OPERANDS; ++i) { ins.obufp =3D ins.op_out[i]; ins.op_ad =3D MAX_OPERANDS - 1 - i; if (dp->op[i].rtn && !dp->op[i].rtn (&ins, dp->op[i].bytemode, sizeflag)) - return fetch_error (&ins); + goto fetch_error_out; /* For EVEX instruction after the last operand masking should be printed. */ if (i =3D=3D 0 && ins.vex.evex) @@ -10061,14 +10068,16 @@ print_insn (bfd_vma pc, disassemble_info *info, i= nt intel_syntax) if (ins.need_vex && ins.vex.register_specifier !=3D 0) { i386_dis_printf (&ins, dis_style_text, "(bad)"); - return ins.end_codep - priv.the_buffer; + ret =3D ins.end_codep - priv.the_buffer; + goto out; } =20 /* If EVEX.z is set, there must be an actual mask register in use. */ if (ins.vex.zeroing && ins.vex.mask_register_specifier =3D=3D 0) { i386_dis_printf (&ins, dis_style_text, "(bad)"); - return ins.end_codep - priv.the_buffer; + ret =3D ins.end_codep - priv.the_buffer; + goto out; } =20 switch (dp->prefix_requirement) @@ -10079,7 +10088,8 @@ print_insn (bfd_vma pc, disassemble_info *info, int= intel_syntax) if (ins.need_vex ? !ins.vex.prefix : !(ins.prefixes & PREFIX_DATA)) { i386_dis_printf (&ins, dis_style_text, "(bad)"); - return ins.end_codep - priv.the_buffer; + ret =3D ins.end_codep - priv.the_buffer; + goto out; } ins.used_prefixes |=3D PREFIX_DATA; /* Fall through. */ @@ -10106,7 +10116,8 @@ print_insn (bfd_vma pc, disassemble_info *info, int= intel_syntax) && !ins.vex.w !=3D !(ins.used_prefixes & PREFIX_DATA))) { i386_dis_printf (&ins, dis_style_text, "(bad)"); - return ins.end_codep - priv.the_buffer; + ret =3D ins.end_codep - priv.the_buffer; + goto out; } break; =20 @@ -10162,7 +10173,8 @@ print_insn (bfd_vma pc, disassemble_info *info, int= intel_syntax) if ((ins.codep - ins.start_codep) > MAX_CODE_LENGTH) { i386_dis_printf (&ins, dis_style_text, "(bad)"); - return MAX_CODE_LENGTH; + ret =3D MAX_CODE_LENGTH; + goto out; } =20 /* Calculate the number of operands this instruction has. */ @@ -10270,7 +10282,10 @@ print_insn (bfd_vma pc, disassemble_info *info, in= t intel_syntax) info); break; } - return ins.codep - priv.the_buffer; + ret =3D ins.codep - priv.the_buffer; + out: + info->private_data =3D NULL; + return ret; } =20 /* Here for backwards compatibility. When gdb stops using