]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas various other void* casts
authorAlan Modra <amodra@gmail.com>
Tue, 8 Jul 2025 23:33:45 +0000 (09:03 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 9 Jul 2025 00:05:07 +0000 (09:35 +0930)
This removes assorted unneeded casts of void* pointers, and casts when
passing args to void* parameters or storing to void* pointers.  The
patch also changes obj-coff.c stack_push to take a void* parameter,
and replaces an odd memcpy in tc-metag.c find_insn_templates with a
simple assignment.

20 files changed:
gas/config/obj-coff.c
gas/config/obj-elf.c
gas/config/obj-evax.c
gas/config/obj-macho.c
gas/config/tc-aarch64.c
gas/config/tc-arc.c
gas/config/tc-hppa.c
gas/config/tc-m32r.c
gas/config/tc-metag.c
gas/config/tc-mmix.c
gas/config/tc-riscv.c
gas/config/tc-score.c
gas/config/tc-sh.c
gas/config/tc-sparc.c
gas/config/tc-tic54x.c
gas/config/tc-v850.c
gas/config/tc-vax.c
gas/flonum-copy.c
gas/symbols.c
gas/write.c

index 41cc2dace445e06c3f30d9a2cc2f8f82061d95b6..3467d646428fe2796162b32c6d60aba6748669d5 100644 (file)
@@ -90,7 +90,7 @@ stack_init (unsigned long chunk_size,
 }
 
 static char *
-stack_push (stack *st, char *element)
+stack_push (stack *st, void *element)
 {
   if (st->pointer + st->element_size >= st->size)
     {
@@ -1325,7 +1325,7 @@ coff_frob_symbol (symbolS *symp, int *punt)
          if (S_GET_STORAGE_CLASS (symp) == C_BLOCK)
            {
              if (streq (S_GET_NAME (symp), ".bb"))
-               stack_push (block_stack, (char *) &symp);
+               stack_push (block_stack, &symp);
              else
                {
                  symbolS *begin;
index 9342d11eb11035ecf48e6e47961a38fd5deafbbc..8eb267d7782c0f0be9861f09b7dcee594c57037c 100644 (file)
@@ -481,7 +481,7 @@ match_section (const asection *sec, const struct elf_section_match *match)
 static bool
 get_section_by_match (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf)
 {
-  struct elf_section_match *match = (struct elf_section_match *) inf;
+  struct elf_section_match *match = inf;
   const char *gname = match->group_name;
   const char *group_name = elf_group_name (sec);
 
@@ -614,7 +614,7 @@ change_section (const char *name,
     old_sec = group_section_find (match_p, name, &group_idx);
   else
     old_sec = bfd_get_section_by_name_if (stdoutput, name, get_section_by_match,
-                                         (void *) match_p);
+                                         match_p);
   if (old_sec)
     {
       sec = old_sec;
index c5317e8b4349a8d67dc0bffc4c331d21a5652853..9fbde27baffc09dc28a3c4f4b0b8658260d39d60 100644 (file)
@@ -107,8 +107,7 @@ evax_frob_symbol (symbolS *sym, int *punt)
 
   else if ((symbol->flags & BSF_GLOBAL) && (symbol->flags & BSF_FUNCTION))
     {
-      struct evax_private_udata_struct *udata
-       = (struct evax_private_udata_struct *)symbol->udata.p;
+      struct evax_private_udata_struct *udata = symbol->udata.p;
 
       /* Fix up equates of function definitions.  */
       while (udata->enbsym == NULL)
index adcdb99c740de423fcae51a817b33def838f2518..c7171244acfa54faa20e1ca3395640c711d86c52 100644 (file)
@@ -1698,7 +1698,7 @@ obj_mach_o_set_section_vma (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *v_p
 {
   bfd_mach_o_section *ms = bfd_mach_o_get_mach_o_section (sec);
   unsigned bfd_align = bfd_section_alignment (sec);
-  obj_mach_o_set_vma_data *p = (struct obj_mach_o_set_vma_data *)v_p;
+  obj_mach_o_set_vma_data *p = v_p;
   unsigned sectype = (ms->flags & BFD_MACH_O_SECTION_TYPE_MASK);
   unsigned zf;
 
@@ -1741,11 +1741,11 @@ void obj_mach_o_post_relax_hook (void)
 
   memset (&d, 0, sizeof (d));
 
-  bfd_map_over_sections (stdoutput, obj_mach_o_set_section_vma, (char *) &d);
+  bfd_map_over_sections (stdoutput, obj_mach_o_set_section_vma, &d);
   if ((d.vma_pass = d.zerofill_seen) != 0)
-    bfd_map_over_sections (stdoutput, obj_mach_o_set_section_vma, (char *) &d);
+    bfd_map_over_sections (stdoutput, obj_mach_o_set_section_vma, &d);
   if ((d.vma_pass = d.gb_zerofill_seen) != 0)
-    bfd_map_over_sections (stdoutput, obj_mach_o_set_section_vma, (char *) &d);
+    bfd_map_over_sections (stdoutput, obj_mach_o_set_section_vma, &d);
 }
 
 static void
@@ -1777,8 +1777,7 @@ obj_mach_o_set_indirect_symbols (bfd *abfd, asection *sec,
          obj_mach_o_indirect_sym *isym;
          obj_mach_o_indirect_sym *list = NULL;
          obj_mach_o_indirect_sym *list_tail = NULL;
-         unsigned long eltsiz =
-                       bfd_mach_o_section_get_entry_size (abfd, ms);
+         unsigned long eltsiz = bfd_mach_o_section_get_entry_size (abfd, ms);
 
          for (isym = indirect_syms; isym != NULL; isym = isym->next)
            {
index 32fe7b83c067b3963439706bbfb4052c9b34c8e3..b52d4b705de398dc8be3fb46d68afa7c6131cb05 100644 (file)
@@ -5622,7 +5622,7 @@ static const char *aarch64_apply_style
 {
   int res;
   char *ptr;
-  struct obstack *stack = (struct obstack *) styler->state;
+  struct obstack *stack = styler->state;
   va_list ap;
 
   /* Calculate the required space.  */
@@ -5651,7 +5651,7 @@ print_operands (char *buf, const aarch64_opcode *opcode,
   obstack_init (&content);
 
   styler.apply_style = aarch64_apply_style;
-  styler.state = (void *) &content;
+  styler.state = &content;
 
   for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
     {
index cd1ef338379c7d3fe9be3758d696e7de892d4f16..4c27c60c0e34829e66783ba6f5246078f838e3ce 100644 (file)
@@ -778,7 +778,7 @@ arc_insert_opcode (const struct arc_opcode *opcode)
 static void
 arc_opcode_free (void *elt)
 {
-  string_tuple_t *tuple = (string_tuple_t *) elt;
+  string_tuple_t *tuple = elt;
   struct arc_opcode_hash_entry *entry = (void *) tuple->value;
   free (entry->opcode);
   free (entry);
index 3240e8d1a7a50721a22477d5bc174320de1954cb..b147bdc1713fb1a658865884556a2b3c4547f395 100644 (file)
@@ -1200,7 +1200,7 @@ fix_new_hppa (fragS *frag,
     new_fix = fix_new_exp (frag, where, size, exp, pcrel, r_type);
   else
     new_fix = fix_new (frag, where, size, add_symbol, offset, pcrel, r_type);
-  new_fix->tc_fix_data = (void *) hppa_fix;
+  new_fix->tc_fix_data = hppa_fix;
   hppa_fix->fx_r_type = r_type;
   hppa_fix->fx_r_field = r_field;
   hppa_fix->fx_r_format = r_format;
@@ -1351,7 +1351,7 @@ tc_gen_reloc (asection *section, fixS *fixp)
   if (fixp->fx_addsy == 0)
     return &no_relocs;
 
-  hppa_fixp = (struct hppa_fix_struct *) fixp->tc_fix_data;
+  hppa_fixp = fixp->tc_fix_data;
   gas_assert (hppa_fixp != 0);
   gas_assert (section != 0);
 
@@ -1726,7 +1726,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
     fixP->fx_done = 1;
 
   /* There should be a HPPA specific fixup associated with the GAS fixup.  */
-  hppa_fixP = (struct hppa_fix_struct *) fixP->tc_fix_data;
+  hppa_fixP = fixP->tc_fix_data;
   if (hppa_fixP == NULL)
     {
       as_bad_where (fixP->fx_file, fixP->fx_line,
@@ -8317,7 +8317,7 @@ hppa_fix_adjustable (fixS *fixp)
 #endif
   struct hppa_fix_struct *hppa_fix;
 
-  hppa_fix = (struct hppa_fix_struct *) fixp->tc_fix_data;
+  hppa_fix = fixp->tc_fix_data;
 
 #ifdef OBJ_ELF
   /* LR/RR selectors are implicitly used for a number of different relocation
@@ -8436,7 +8436,7 @@ hppa_force_relocation (struct fix *fixp)
 {
   struct hppa_fix_struct *hppa_fixp;
 
-  hppa_fixp = (struct hppa_fix_struct *) fixp->tc_fix_data;
+  hppa_fixp = fixp->tc_fix_data;
 #ifdef OBJ_SOM
   if (fixp->fx_r_type == (int) R_HPPA_ENTRY
       || fixp->fx_r_type == (int) R_HPPA_EXIT
@@ -8545,7 +8545,7 @@ pa_vtable_entry (int ignore ATTRIBUTE_UNUSED)
       hppa_fix->fx_r_format = 32;
       hppa_fix->fx_arg_reloc = 0;
       hppa_fix->segment = now_seg;
-      new_fix->tc_fix_data = (void *) hppa_fix;
+      new_fix->tc_fix_data = hppa_fix;
       new_fix->fx_r_type = (int) R_PARISC_GNU_VTENTRY;
     }
 }
@@ -8566,7 +8566,7 @@ pa_vtable_inherit (int ignore ATTRIBUTE_UNUSED)
       hppa_fix->fx_r_format = 32;
       hppa_fix->fx_arg_reloc = 0;
       hppa_fix->segment = now_seg;
-      new_fix->tc_fix_data = (void *) hppa_fix;
+      new_fix->tc_fix_data = hppa_fix;
       new_fix->fx_r_type = (int) R_PARISC_GNU_VTINHERIT;
     }
 }
index 2bd32afab1d3827cf1c85ea0ebc10a14fb9fa4fa..de51726d2b7faecac07bb16ccf998c1f4ec23b9d 100644 (file)
@@ -615,7 +615,7 @@ expand_debug_syms (sym_linkS *syms, int align)
       next_syms = syms->next;
       input_line_pointer = (char *) ".\n";
       pseudo_set (symbolP);
-      free ((char *) syms);
+      free (syms);
     }
 
   input_line_pointer = save_input_line;
index e6ba16ce188026b20f455f5e80c4f0b6428b5b08..c367a8fca9c3084129b909d2f6278a8295735738 100644 (file)
@@ -6263,10 +6263,9 @@ find_insn_templates (const char *mnemonic)
   insn_templates *slot;
 
   entry.template = &template;
+  template.name = mnemonic;
 
-  memcpy ((void *)&entry.template->name, &mnemonic, sizeof (char *));
-
-  slot = (insn_templates *) htab_find (mnemonic_htab, &entry);
+  slot = htab_find (mnemonic_htab, &entry);
 
   if (slot)
     return slot;
@@ -6307,8 +6306,8 @@ hash_templates (const void *p)
 static int
 eq_templates (const void *a, const void *b)
 {
-  insn_templates *ta = (insn_templates *)a;
-  insn_templates *tb = (insn_templates *)b;
+  const insn_templates *ta = a;
+  const insn_templates *tb = b;
   return strcasecmp (ta->template->name, tb->template->name) == 0;
 }
 
@@ -6456,8 +6455,8 @@ hash_scond (const void *p)
 static int
 eq_scond (const void *a, const void *b)
 {
-  split_condition *ra = (split_condition *)a;
-  split_condition *rb = (split_condition *)b;
+  const split_condition *ra = a;
+  const split_condition *rb = b;
 
   return strcasecmp (ra->name, rb->name) == 0;
 }
index 631dcc924e6a6e782ffcbba4dbc005d3d9d78ce2..d86ae7a25ded2bbd21b079fe5e14c99c938477f1 100644 (file)
@@ -3686,10 +3686,8 @@ mmix_md_finish (void)
 static int
 cmp_greg_symbol_fixes (const void *parg, const void *qarg)
 {
-  const struct mmix_symbol_greg_fixes *p
-    = (const struct mmix_symbol_greg_fixes *) parg;
-  const struct mmix_symbol_greg_fixes *q
-    = (const struct mmix_symbol_greg_fixes *) qarg;
+  const struct mmix_symbol_greg_fixes *p = parg;
+  const struct mmix_symbol_greg_fixes *q = qarg;
 
   return p->offs > q->offs ? 1 : p->offs < q->offs ? -1 : 0;
 }
index 6db93fd10bdf765ffdf486ac72c9a6b8f76ea6da..0492311b40a9ac729c6d5be8a22707b8b92e131e 100644 (file)
@@ -538,7 +538,7 @@ make_mapping_symbol (enum riscv_seg_mstate state,
     {
       /* Store current $x+arch into tc_segment_info.  */
       seg_info (now_seg)->tc_segment_info_data.arch_map_symbol = symbol;
-      xfree ((void *) buff);
+      xfree (buff);
     }
 
   /* If .fill or other data filling directive generates zero sized data,
@@ -5753,7 +5753,7 @@ riscv_insert_uleb128_fixes (bfd *abfd ATTRIBUTE_UNUSED,
       exp_dup->X_add_number = 0; /* Set addend of SUB_ULEB128 to zero.  */
       fix_new_exp (fragP, fragP->fr_fix, 0,
                   exp_dup, 0, BFD_RELOC_RISCV_SUB_ULEB128);
-      free ((void *) exp_dup);
+      free (exp_dup);
     }
 }
 
index 47f30501756b39905924fb441396443eadc713d3..10795a7de5319c353fc375fa0970d00f0e0dc9b9 100644 (file)
@@ -6504,7 +6504,7 @@ s3_normal_chars_to_number (const char *buf, int n)
 static void
 s3_number_to_chars_littleendian (void *p, valueT data, int n)
 {
-  char *buf = (char *) p;
+  char *buf = p;
 
   switch (n)
     {
index d49abc25501a8e8428fb7d96d78fcd388b2ff94f..6d077b27a74af4b1552e41344ab38ebad52aaa30 100644 (file)
@@ -2871,7 +2871,7 @@ struct sh_count_relocs
 static void
 sh_count_relocs (bfd *abfd ATTRIBUTE_UNUSED, segT sec, void *data)
 {
-  struct sh_count_relocs *info = (struct sh_count_relocs *) data;
+  struct sh_count_relocs *info = data;
   segment_info_type *seginfo;
   symbolS *sym;
   fixS *fix;
index f71b743c64e709fef2d1533a417f3de2f24e35ea..321a21299e9c6d06f6532eae54b4d0afe8cafa34 100644 (file)
@@ -805,8 +805,8 @@ struct priv_reg_entry v9a_asr_table[] =
 static int
 cmp_reg_entry (const void *parg, const void *qarg)
 {
-  const struct priv_reg_entry *p = (const struct priv_reg_entry *) parg;
-  const struct priv_reg_entry *q = (const struct priv_reg_entry *) qarg;
+  const struct priv_reg_entry *p = parg;
+  const struct priv_reg_entry *q = qarg;
 
   if (p->name == q->name)
     return 0;
@@ -921,8 +921,8 @@ struct perc_entry perc_table[NUM_PERC_ENTRIES];
 static int
 cmp_perc_entry (const void *parg, const void *qarg)
 {
-  const struct perc_entry *p = (const struct perc_entry *) parg;
-  const struct perc_entry *q = (const struct perc_entry *) qarg;
+  const struct perc_entry *p = parg;
+  const struct perc_entry *q = qarg;
 
   if (p->name == q->name)
     return 0;
index 0add19b23eac7f90b7841bf922f2bd25efa09309..b1d5bc1ed430acd17de81b4ea5fedab6b0fdef64 100644 (file)
@@ -1149,7 +1149,7 @@ tic54x_global (int type)
 static void
 free_subsym_ent (void *ent)
 {
-  string_tuple_t *tuple = (string_tuple_t *) ent;
+  string_tuple_t *tuple = ent;
   subsym_ent_t *val = (void *) tuple->value;
   if (val->freekey)
     free ((void *) tuple->key);
@@ -1169,7 +1169,7 @@ subsym_htab_create (void)
 static void
 free_local_label_ent (void *ent)
 {
-  string_tuple_t *tuple = (string_tuple_t *) ent;
+  string_tuple_t *tuple = ent;
   free ((void *) tuple->key);
   free ((void *) tuple->value);
   free (ent);
@@ -2371,7 +2371,7 @@ tic54x_mlib (int ignore ATTRIBUTE_UNUSED)
       /* Write to a temporary file, then use s_include to include it
         a bit of a hack.  */
       ftmp = fopen (fname, "w+b");
-      fwrite ((void *) buf, size, 1, ftmp);
+      fwrite (buf, size, 1, ftmp);
       if (size == 0 || buf[size - 1] != '\n')
        fwrite ("\n", 1, 1, ftmp);
       fclose (ftmp);
index 7aa946175dcc3cab2b853ab793a18ffee4e7fe51..f160ec283c2e34645fc7ba354b13b74011ae9307 100644 (file)
@@ -3509,7 +3509,7 @@ md_apply_fix (fixS *fixP, valueT *valueP, segT seg ATTRIBUTE_UNUSED)
           && ((struct v850_operand *) fixP->tc_fix_data)->insert != NULL)
         {
           const char * message = NULL;
-          struct v850_operand * operand = (struct v850_operand *) fixP->tc_fix_data;
+          struct v850_operand * operand = fixP->tc_fix_data;
           unsigned long insn;
 
           /* The variable "where" currently points at the exact point inside
index dca86dac195d95c86bf368aa471415dd10368696..9670b1aae32c7234a8b0a4fd5d5ed584a85ff33e 100644 (file)
@@ -332,8 +332,7 @@ bignum_copy (LITTLENUM_TYPE *in,
       LITTLENUM_TYPE *p;       /* -> most significant (non-zero) input
                                      littlenum.  */
 
-      memcpy ((void *) out, (void *) in,
-             (unsigned int) out_length << LITTLENUM_SHIFT);
+      memcpy (out, in, (unsigned int) out_length << LITTLENUM_SHIFT);
       for (p = in + in_length - 1; p >= in; --p)
        {
          if (*p)
@@ -346,11 +345,10 @@ bignum_copy (LITTLENUM_TYPE *in,
     }
   else
     {
-      memcpy ((char *) out, (char *) in,
-             (unsigned int) in_length << LITTLENUM_SHIFT);
+      memcpy (out, in, (unsigned int) in_length << LITTLENUM_SHIFT);
 
       if (out_length > in_length)
-       memset ((char *) (out + in_length), '\0',
+       memset (out + in_length, 0,
                (unsigned int) (out_length - in_length) << LITTLENUM_SHIFT);
 
       significant_littlenums_dropped = 0;
index b7554952e2fb551ca2ccbdeee92d98c3d1e15fd9..5c37ad31b049fc0da5cc2235389b7bfaa3db0a76 100644 (file)
@@ -46,12 +46,11 @@ flonum_copy (FLONUM_TYPE *in, FLONUM_TYPE *out)
               and wasting time, so why bother???  */
            if (in_length < out_length)
              {
-               memset ((char *) (out->low + in_length + 1), '\0',
-                       out_length - in_length);
+               memset (out->low + in_length + 1, 0, out_length - in_length);
              }
          }
-         memcpy ((void *) (out->low), (void *) (in->low),
-                 ((in_length + 1) * sizeof (LITTLENUM_TYPE)));
+         memcpy (out->low, in->low,
+                 (in_length + 1) * sizeof (LITTLENUM_TYPE));
          out->exponent = in->exponent;
          out->leader = in->leader - in->low + out->low;
        }
@@ -61,8 +60,8 @@ flonum_copy (FLONUM_TYPE *in, FLONUM_TYPE *out)
 
          shorten = in_length - out_length;
          /* Assume out_length >= 0 ! */
-         memcpy ((void *) (out->low), (void *) (in->low + shorten),
-                 ((out_length + 1) * sizeof (LITTLENUM_TYPE)));
+         memcpy (out->low, in->low + shorten,
+                 (out_length + 1) * sizeof (LITTLENUM_TYPE));
          out->leader = out->high;
          out->exponent = in->exponent + shorten;
        }
index 94d0f4d2acf33938a6c6350c27ae43102c807fee..775736f5a5396acf17eabfa836e5d546c2b7dbbd 100644 (file)
@@ -194,8 +194,8 @@ hash_symbol_entry (const void *e)
 static int
 eq_symbol_entry (const void *a, const void *b)
 {
-  const symbol_entry_t *ea = (const symbol_entry_t *) a;
-  const symbol_entry_t *eb = (const symbol_entry_t *) b;
+  const symbol_entry_t *ea = a;
+  const symbol_entry_t *eb = b;
 
   return (ea->sy.hash == eb->sy.hash
          && strcmp (ea->sy.name, eb->sy.name) == 0);
@@ -464,7 +464,7 @@ local_symbol_make (const char *name, segT section, fragS *frag, valueT val)
 static symbolS *
 local_symbol_convert (void *sym)
 {
-  symbol_entry_t *ent = (symbol_entry_t *) sym;
+  symbol_entry_t *ent = sym;
   struct xsymbol *xtra;
   valueT val;
 
@@ -2059,7 +2059,7 @@ static size_t fb_label_max;
 static void
 fb_label_init (void)
 {
-  memset ((void *) fb_low_counter, '\0', sizeof (fb_low_counter));
+  memset (fb_low_counter, 0, sizeof (fb_low_counter));
 }
 
 /* Add one to the instance number of this fb label.  */
index fcacf202e916373ea702670e8237f85ebb05cf47..02dfcc7001750a400d806b4271a689662f57dd09 100644 (file)
@@ -352,7 +352,7 @@ get_recorded_alignment (segT seg)
 static void
 renumber_sections (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *countparg)
 {
-  int *countp = (int *) countparg;
+  int *countp = countparg;
 
   sec->index = *countp;
   ++*countp;
@@ -553,7 +553,7 @@ static void
 relax_seg (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *xxx)
 {
   segment_info_type *seginfo = seg_info (sec);
-  struct relax_seg_info *info = (struct relax_seg_info *) xxx;
+  struct relax_seg_info *info = xxx;
 
   if (seginfo && seginfo->frchainP
       && relax_segment (seginfo->frchainP->frch_root, sec, info->pass))