RISC-V: Fix printf argument types corresponding %x
authorTsukasa OI <research_trasio@irq.a4lg.com>
Wed, 13 Jul 2022 13:33:07 +0000 (22:33 +0900)
committerTsukasa OI <research_trasio@irq.a4lg.com>
Thu, 6 Oct 2022 02:23:31 +0000 (02:23 +0000)
"%x" format specifier requires unsigned type, not int.  This commit
fixes this issue on the RISC-V disassembler.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Fix printf argument types where
the format specifier is "%x".

opcodes/riscv-dis.c

index 0070b2323c02fb0de5fce29e36082825bdaea1b8..ae35790d43b3ffa0dbda4acf3d53f78c1081ebc0 100644 (file)
@@ -292,15 +292,15 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info
              break;
            case 'u':
              print (info->stream, dis_style_immediate, "0x%x",
-                    (int)(EXTRACT_CITYPE_IMM (l) & (RISCV_BIGIMM_REACH-1)));
+                    (unsigned)(EXTRACT_CITYPE_IMM (l) & (RISCV_BIGIMM_REACH-1)));
              break;
            case '>':
              print (info->stream, dis_style_immediate, "0x%x",
-                    (int)EXTRACT_CITYPE_IMM (l) & 0x3f);
+                    (unsigned)EXTRACT_CITYPE_IMM (l) & 0x3f);
              break;
            case '<':
              print (info->stream, dis_style_immediate, "0x%x",
-                    (int)EXTRACT_CITYPE_IMM (l) & 0x1f);
+                    (unsigned)EXTRACT_CITYPE_IMM (l) & 0x1f);
              break;
            case 'T': /* Floating-point RS2.  */
              print (info->stream, dis_style_register, "%s",
@@ -481,7 +481,7 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info
 
        case 'y':
          print (info->stream, dis_style_immediate, "0x%x",
-                (int)EXTRACT_OPERAND (BS, l));
+                (unsigned)EXTRACT_OPERAND (BS, l));
          break;
 
        case 'z':
@@ -490,12 +490,12 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info
 
        case '>':
          print (info->stream, dis_style_immediate, "0x%x",
-                (int)EXTRACT_OPERAND (SHAMT, l));
+                (unsigned)EXTRACT_OPERAND (SHAMT, l));
          break;
 
        case '<':
          print (info->stream, dis_style_immediate, "0x%x",
-                (int)EXTRACT_OPERAND (SHAMTW, l));
+                (unsigned)EXTRACT_OPERAND (SHAMTW, l));
          break;
 
        case 'S':
@@ -556,7 +556,7 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info
 
        case 'Y':
          print (info->stream, dis_style_immediate, "0x%x",
-                (int) EXTRACT_OPERAND (RNUM, l));
+                (unsigned) EXTRACT_OPERAND (RNUM, l));
          break;
 
        case 'Z':