]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix even more -Wdiscarded-qualifers issues
authorKeith Seitz <keiths@redhat.com>
Wed, 25 Feb 2026 14:24:53 +0000 (06:24 -0800)
committerKeith Seitz <keiths@redhat.com>
Wed, 25 Feb 2026 14:48:22 +0000 (06:48 -0800)
Fedora Rawhide is failing to build due to new glibc header changes
enforcing const-correctness in functions like strchr and memchr.
For example:

../../opcodes/aarch64-dis.c: In function ‘remove_dot_suffix’:
../../opcodes/aarch64-dis.c:4027:7: error: assignment discards ‘const’ qualifier from po
inter target type [-Werror=discarded-qualifiers]
 4027 |   ptr = strchr (inst->opcode->name, '.');
      |       ^
cc1: all warnings being treated as errors

This patch addresses all the discovered issues with --enable-targets=all
and regenerates a few cgen files along the way.

cpu/ip2k.opc
opcodes/aarch64-dis.c
opcodes/ia64-opc.c
opcodes/ip2k-asm.c
opcodes/riscv-dis.c
opcodes/tilegx-opc.c
opcodes/tilepro-opc.c

index 512c3f3aea88f5caa7d20f2d3b443a9cd5c94a70..c89f61d8942ed7cbf0d185ebbd2ed762fd1922c4 100644 (file)
@@ -94,7 +94,7 @@ parse_fr (CGEN_CPU_DESC cd,
 {
   const char *errmsg;
   const char *old_strp;
-  char *afteroffset; 
+  const char *afteroffset;
   enum cgen_parse_operand_result result_type;
   bfd_vma value;
   extern CGEN_KEYWORD ip2k_cgen_opval_register_names;
index 8cc2eb3f3c2013a04294edbf0fe4379239243f53..f09307847e640e10a627caf6880f4536db96dc3d 100644 (file)
@@ -4087,7 +4087,7 @@ print_operands (bfd_vma pc, const aarch64_opcode *opcode,
 static void
 remove_dot_suffix (char *name, const aarch64_inst *inst)
 {
-  char *ptr;
+  const char *ptr;
   size_t len;
 
   ptr = strchr (inst->opcode->name, '.');
index 5d79cf3d041a0126d469cb67d0b6eb0ba7c08ca3..79c12a840a749c0b1e383d15f4e9f19eeec38b02 100644 (file)
@@ -66,7 +66,7 @@ const struct ia64_templ_desc ia64_templ_desc[16] =
 static void
 get_opc_prefix (const char **ptr, char *dest)
 {
-  char *c = strchr (*ptr, '.');
+  const char *c = strchr (*ptr, '.');
   if (c != NULL)
     {
       memcpy (dest, *ptr, c - *ptr);
index 18bd98a284633ae335b9b9418480e515f18460fb..3adbd1546a383a492225fd87d852d972d7e942e0 100644 (file)
@@ -59,7 +59,7 @@ parse_fr (CGEN_CPU_DESC cd,
 {
   const char *errmsg;
   const char *old_strp;
-  char *afteroffset;
+  const char *afteroffset;
   enum cgen_parse_operand_result result_type;
   bfd_vma value;
   extern CGEN_KEYWORD ip2k_cgen_opval_register_names;
index 03c8cf1e344cd31402044b278ec2f128d676d649..eda802ff42027ea24cb608d8186363811d193c31 100644 (file)
@@ -110,7 +110,7 @@ parse_riscv_dis_option_without_args (const char *option,
 /* Parse RISC-V disassembler option (possibly with arguments).  */
 
 static void
-parse_riscv_dis_option (const char *option, struct disassemble_info *info)
+parse_riscv_dis_option (char *option, struct disassemble_info *info)
 {
   char *equal, *value;
 
@@ -1140,7 +1140,7 @@ riscv_update_map_state (int n,
 
       /* ISA mapping string may be numbered, suffixed with '.n'. Do not
         consider this as part of the ISA string.  */
-      char *suffix = strchr (name, '.');
+      const char *suffix = strchr (name, '.');
       if (suffix)
        {
          int suffix_index = (int)(suffix - name);
index db762e2249325f10b742a4c3bd0642a0da017880..a1d42d6e18d01a37a8b705cf1802c6507f5df714 100644 (file)
@@ -8003,7 +8003,7 @@ tilegx_spr_compare (const void *a_ptr, const void *b_ptr)
 const char *
 get_tilegx_spr_name (int num)
 {
-  void *result;
+  const void *result;
   struct tilegx_spr key;
 
   key.number = num;
index 664122b05d5185bcaf2da6db04610ebb491ee9cd..d3d580fae9de3e5257b7a292cd9cbeb80f93a222 100644 (file)
@@ -10119,7 +10119,7 @@ tilepro_spr_compare (const void *a_ptr, const void *b_ptr)
 const char *
 get_tilepro_spr_name (int num)
 {
-  void *result;
+  const void *result;
   struct tilepro_spr key;
 
   key.number = num;
@@ -10131,7 +10131,7 @@ get_tilepro_spr_name (int num)
     return NULL;
 
   {
-    struct tilepro_spr *result_ptr = (struct tilepro_spr *) result;
+    const struct tilepro_spr *result_ptr = (const struct tilepro_spr *) result;
 
     return result_ptr->name;
   }