]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/build] Fix Wformat errors in gdb/riscv-tdep.c
authorTom de Vries <tdevries@suse.de>
Wed, 30 Apr 2025 07:49:58 +0000 (09:49 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 30 Apr 2025 07:49:58 +0000 (09:49 +0200)
When building gdb with --enable-targets=all on arm-linux, I run into:
...
gdb/riscv-tdep.c: In function ‘bool try_read(regcache*, int, ULONGEST&)’:
gdb/riscv-tdep.c:4887:18: error: format ‘%lx’ expects argument of type \
  ‘long unsigned int’, but argument 2 has type ‘ULONGEST’ \
  {aka ‘long long unsigned int’} [-Werror=format=]
 4887 |       warning (_("Can not read at address %lx"), addr);
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
and a few more Wformat errors, due to commit b9c7eed0c24 ("This commit adds
record full support for rv64gc instruction set").

Fix these by using hex_string.

Tested by completing a build on arm-linux.

gdb/riscv-tdep.c

index a735c095b0de3c3c0a4797c3005156a3b4b1373d..8998a29731572c326063a039a10c8f9340a74868 100644 (file)
@@ -4884,7 +4884,7 @@ try_read (struct regcache *regcache, int regnum, ULONGEST &addr)
   if (regcache->raw_read (regnum, &addr)
       != register_status::REG_VALID)
     {
-      warning (_("Can not read at address %lx"), addr);
+      warning (_("Can not read at address %s"), hex_string (addr));
       return false;
     }
   return true;
@@ -5270,8 +5270,8 @@ private:
        || try_save_pc_rd_mem (ival, regcache))
       return !has_error ();
 
-    warning (_("Currently this instruction with len 4(%lx) is unsupported"),
-            ival);
+    warning (_("Currently this instruction with len 4(%s) is unsupported"),
+            hex_string (ival));
     return false;
   }
 
@@ -5380,8 +5380,8 @@ private:
               || !save_mem (addr + offset, 4) || set_ordinary_record_type ());
       }
 
-    warning (_("Currently this instruction with len 2(%lx) is unsupported"),
-            ival);
+    warning (_("Currently this instruction with len 2(%s) is unsupported"),
+            hex_string (ival));
     return false;
   }
 
@@ -5415,7 +5415,8 @@ public:
        are not defined yet, so just ignore it.  */
     gdb_assert (m_length > 0 && m_length % 2 == 0);
 
-    warning (_("Can not record unknown instruction (opcode = %lx)"), ival);
+    warning (_("Can not record unknown instruction (opcode = %s)"),
+            hex_string (ival));
     return false;
   }