]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
opcodes: fix Werror=format build breaker in opcodes/riscv-dis.c
authorTom de Vries <tdevries@suse.de>
Sun, 24 Nov 2024 08:21:28 +0000 (09:21 +0100)
committerTom de Vries <tdevries@suse.de>
Sun, 24 Nov 2024 08:21:28 +0000 (09:21 +0100)
I build gdb on arm-linux and ran into:
...
  CC       riscv-dis.lo
opcodes/riscv-dis.c: In function ‘print_insn_args’:
opcodes/riscv-dis.c:743:29: error: format ‘%lu’ expects argument of type \
  ‘long unsigned int’, but argument 4 has type ‘insn_t’ \
  {aka ‘long long unsigned int’} [-Werror=format=]
  743 |                          "%lu", EXTRACT_ZCMT_INDEX (l));
      |                           ~~^
      |                             |
      |                             long unsigned int
      |                           %llu
...

Fix this by printing the insn_t value, which is a uint64_t, using PRIu64.

Tested by finishing the build.

opcodes/riscv-dis.c

index 101380f93aafbd528ba0020371f0c43a85f41bd1..c1212b14a05da1b3a598900254e19f9758f84a63 100644 (file)
@@ -740,7 +740,7 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info
                case 'i':
                case 'I':
                  print (info->stream, dis_style_address_offset,
-                        "%lu", EXTRACT_ZCMT_INDEX (l));
+                        "%" PRIu64, EXTRACT_ZCMT_INDEX (l));
                  break;
                default:
                  goto undefined_modifier;