RISC-V: Adjust the 'print_insn' return value of disassembling.

Message ID 20230317015323.567132-1-jiawei@iscas.ac.cn
State Accepted
Headers
Series RISC-V: Adjust the 'print_insn' return value of disassembling. |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

Jiawei March 17, 2023, 1:53 a.m. UTC
  This bug reported in
https://sourceware.org/bugzilla/show_bug.cgi?id=30184
And discussed in
https://sourceware.org/pipermail/binutils/2023-February/126213.html

We also checked the implementation of return value in arm and mips.
So this patch changes the return value to -1, that can fix bugs and maintain
consistency with other architectures.

opcodes/ChangeLog:

        * riscv-dis.c (print_insn_riscv):Change the return value.

---
 opcodes/riscv-dis.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Nelson Chu March 17, 2023, 2:26 a.m. UTC | #1
OK, looks reasonable and good, please commit.

Thanks
Nelson

On Fri, Mar 17, 2023 at 9:54 AM Jiawei <jiawei@iscas.ac.cn> wrote:
>
> This bug reported in
> https://sourceware.org/bugzilla/show_bug.cgi?id=30184
> And discussed in
> https://sourceware.org/pipermail/binutils/2023-February/126213.html
>
> We also checked the implementation of return value in arm and mips.
> So this patch changes the return value to -1, that can fix bugs and maintain
> consistency with other architectures.
>
> opcodes/ChangeLog:
>
>         * riscv-dis.c (print_insn_riscv):Change the return value.
>
> ---
>  opcodes/riscv-dis.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
> index 7baba054daa..1506dc5750b 100644
> --- a/opcodes/riscv-dis.c
> +++ b/opcodes/riscv-dis.c
> @@ -1059,7 +1059,7 @@ print_insn_riscv (bfd_vma memaddr, struct disassemble_info *info)
>        if (status != 0)
>         {
>           (*info->memory_error_func) (status, memaddr, info);
> -         return status;
> +         return -1;
>         }
>        insn = (insn_t) bfd_getl16 (packet);
>        dump_size = riscv_insn_length (insn);
> --
> 2.25.1
>
  

Patch

diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 7baba054daa..1506dc5750b 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -1059,7 +1059,7 @@  print_insn_riscv (bfd_vma memaddr, struct disassemble_info *info)
       if (status != 0)
 	{
 	  (*info->memory_error_func) (status, memaddr, info);
-	  return status;
+	  return -1;
 	}
       insn = (insn_t) bfd_getl16 (packet);
       dump_size = riscv_insn_length (insn);