aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2025-07-09 09:02:28 +0930
committerAlan Modra <amodra@gmail.com>2025-07-09 09:35:07 +0930
commit60ba816bc1dba2435f0dc03ce1ffca0fd7254719 (patch)
treef2e0c322e82c10998d37da1ecd70bce500e1c127
parent3dcea21160ede74436f05aa519032337caa57241 (diff)
downloadbinutils-60ba816bc1dba2435f0dc03ce1ffca0fd7254719.zip
binutils-60ba816bc1dba2435f0dc03ce1ffca0fd7254719.tar.gz
binutils-60ba816bc1dba2435f0dc03ce1ffca0fd7254719.tar.bz2
gas alloc casts
All of the various memory allocation function return a "void *" pointer, which needs no cast to assign to other pointer types.
-rw-r--r--gas/cond.c15
-rw-r--r--gas/config/obj-coff.c4
-rw-r--r--gas/config/obj-elf.c2
-rw-r--r--gas/config/tc-aarch64.c2
-rw-r--r--gas/config/tc-arc.c2
-rw-r--r--gas/config/tc-arm.c2
-rw-r--r--gas/config/tc-bfin.c8
-rw-r--r--gas/config/tc-csky.c3
-rw-r--r--gas/config/tc-kvx.c2
-rw-r--r--gas/config/tc-loongarch.c2
-rw-r--r--gas/config/tc-mips.c2
-rw-r--r--gas/config/tc-riscv.c10
-rw-r--r--gas/config/tc-xtensa.c2
-rw-r--r--gas/ecoff.c4
-rw-r--r--gas/frags.c2
-rw-r--r--gas/read.c4
-rw-r--r--gas/subsegs.c2
-rw-r--r--gas/write.c2
18 files changed, 31 insertions, 39 deletions
diff --git a/gas/cond.c b/gas/cond.c
index 27898df..2e3b3fd 100644
--- a/gas/cond.c
+++ b/gas/cond.c
@@ -110,8 +110,7 @@ s_ifdef (int test_defined)
cframe.ignoring = ! (test_defined ^ is_defined);
}
- current_cframe =
- (struct conditional_frame *) obstack_alloc (&cond_obstack, sizeof cframe);
+ current_cframe = obstack_alloc (&cond_obstack, sizeof cframe);
memcpy (current_cframe, &cframe, sizeof cframe);
if (LISTING_SKIP_COND ()
@@ -168,8 +167,7 @@ s_if (int arg)
using an undefined result. No big deal. */
initialize_cframe (&cframe);
cframe.ignoring = cframe.dead_tree || ! t;
- current_cframe =
- (struct conditional_frame *) obstack_alloc (&cond_obstack, sizeof cframe);
+ current_cframe = obstack_alloc (&cond_obstack, sizeof cframe);
memcpy (current_cframe, & cframe, sizeof cframe);
if (LISTING_SKIP_COND ()
@@ -205,8 +203,7 @@ s_ifb (int test_blank)
cframe.ignoring = (test_blank == !is_eol);
}
- current_cframe =
- (struct conditional_frame *) obstack_alloc (&cond_obstack, sizeof cframe);
+ current_cframe = obstack_alloc (&cond_obstack, sizeof cframe);
memcpy (current_cframe, &cframe, sizeof cframe);
if (LISTING_SKIP_COND ()
@@ -286,8 +283,7 @@ s_ifc (int arg)
initialize_cframe (&cframe);
cframe.ignoring = cframe.dead_tree || ! (res ^ arg);
- current_cframe =
- (struct conditional_frame *) obstack_alloc (&cond_obstack, sizeof cframe);
+ current_cframe = obstack_alloc (&cond_obstack, sizeof cframe);
memcpy (current_cframe, &cframe, sizeof cframe);
if (LISTING_SKIP_COND ()
@@ -481,8 +477,7 @@ s_ifeqs (int arg)
initialize_cframe (&cframe);
cframe.ignoring = cframe.dead_tree || ! (res ^ arg);
- current_cframe =
- (struct conditional_frame *) obstack_alloc (&cond_obstack, sizeof cframe);
+ current_cframe = obstack_alloc (&cond_obstack, sizeof cframe);
memcpy (current_cframe, &cframe, sizeof cframe);
if (LISTING_SKIP_COND ()
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c
index a926548..41cc2da 100644
--- a/gas/config/obj-coff.c
+++ b/gas/config/obj-coff.c
@@ -369,10 +369,10 @@ void
coff_obj_symbol_new_hook (symbolS *symbolP)
{
size_t sz = (OBJ_COFF_MAX_AUXENTRIES + 1) * sizeof (combined_entry_type);
- char *s = notes_alloc (sz);
+ combined_entry_type *s = notes_alloc (sz);
memset (s, 0, sz);
- coffsymbol (symbol_get_bfdsym (symbolP))->native = (combined_entry_type *) s;
+ coffsymbol (symbol_get_bfdsym (symbolP))->native = s;
coffsymbol (symbol_get_bfdsym (symbolP))->native->is_sym = true;
S_SET_DATA_TYPE (symbolP, T_NULL);
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index e2425fe..ff915b5 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -205,7 +205,7 @@ elf_file_symbol (const char *s)
if (name_length > strlen (S_GET_NAME (sym)))
{
obstack_grow (&notes, s, name_length + 1);
- S_SET_NAME (sym, (const char *) obstack_finish (&notes));
+ S_SET_NAME (sym, obstack_finish (&notes));
}
else
strcpy ((char *) S_GET_NAME (sym), s);
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index dd66e00..32fe7b8 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -5632,7 +5632,7 @@ static const char *aarch64_apply_style
gas_assert (res >= 0);
/* Allocate space on the obstack and format the result. */
- ptr = (char *) obstack_alloc (stack, res + 1);
+ ptr = obstack_alloc (stack, res + 1);
res = vsnprintf (ptr, (res + 1), fmt, args);
gas_assert (res >= 0);
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index 83f03c3..aa3a0b2 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -4971,7 +4971,7 @@ arc_stralloc (char * s1, const char * s2)
gas_assert (s2);
len += strlen (s2) + 1;
- p = (char *) xmalloc (len);
+ p = xmalloc (len);
if (s1)
{
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index f6f4eb9..9a1ef1b 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -3701,7 +3701,7 @@ symbol_locate (symbolS * symbolP,
name_length = strlen (name) + 1; /* +1 for \0. */
obstack_grow (&notes, name, name_length);
- preserved_copy_of_name = (char *) obstack_finish (&notes);
+ preserved_copy_of_name = obstack_finish (&notes);
#ifdef tc_canonicalize_symbol_name
preserved_copy_of_name =
diff --git a/gas/config/tc-bfin.c b/gas/config/tc-bfin.c
index d4caa9e..0a635f4 100644
--- a/gas/config/tc-bfin.c
+++ b/gas/config/tc-bfin.c
@@ -937,7 +937,7 @@ Expr_Node_Create (Expr_Node_Type type,
{
- Expr_Node *node = (Expr_Node *) allocate (sizeof (Expr_Node));
+ Expr_Node *node = allocate (sizeof (Expr_Node));
node->type = type;
node->value = value;
node->Left_Child = Left_Child;
@@ -1857,8 +1857,8 @@ bfin_gen_loop (Expr_Node *exp, REG_T reg, int rop, REG_T preg)
symbolS *sym;
loopsym = exp->value.s_value;
- lbeginsym = (char *) xmalloc (strlen (loopsym) + strlen ("__BEGIN") + 5);
- lendsym = (char *) xmalloc (strlen (loopsym) + strlen ("__END") + 5);
+ lbeginsym = xmalloc (strlen (loopsym) + strlen ("__BEGIN") + 5);
+ lendsym = xmalloc (strlen (loopsym) + strlen ("__END") + 5);
lbeginsym[0] = 0;
lendsym[0] = 0;
@@ -1902,7 +1902,7 @@ bfin_loop_beginend (Expr_Node *exp, int begin)
const char *suffix = begin ? "__BEGIN" : "__END";
loopsym = exp->value.s_value;
- label_name = (char *) xmalloc (strlen (loopsym) + strlen (suffix) + 5);
+ label_name = xmalloc (strlen (loopsym) + strlen (suffix) + 5);
label_name[0] = 0;
diff --git a/gas/config/tc-csky.c b/gas/config/tc-csky.c
index 7eaf7a9..9a7749e 100644
--- a/gas/config/tc-csky.c
+++ b/gas/config/tc-csky.c
@@ -7861,8 +7861,7 @@ static void
csky_stack_size (int arg ATTRIBUTE_UNUSED)
{
expressionS exp;
- stack_size_entry *sse
- = (stack_size_entry *) xcalloc (1, sizeof (stack_size_entry));
+ stack_size_entry *sse = xcalloc (1, sizeof (stack_size_entry));
expression (&exp);
if (exp.X_op == O_symbol)
diff --git a/gas/config/tc-kvx.c b/gas/config/tc-kvx.c
index 5582650..501ce1d 100644
--- a/gas/config/tc-kvx.c
+++ b/gas/config/tc-kvx.c
@@ -1644,7 +1644,7 @@ md_apply_fix (fixS * fixP, valueT * valueP, segT segmentP ATTRIBUTE_UNUSED)
valueT image;
arelent *rel;
- rel = (arelent *) xmalloc (sizeof (arelent));
+ rel = xmalloc (sizeof (arelent));
rel->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type);
if (rel->howto == NULL)
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index 06fb601..a91b12e 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -483,7 +483,7 @@ static symbolS *get_align_symbol (segT sec)
&entry, INSERT);
if (slot == NULL)
return NULL;
- *slot = (align_sec_sym *) xmalloc (sizeof (align_sec_sym));
+ *slot = xmalloc (sizeof (align_sec_sym));
if (*slot == NULL)
return NULL;
**slot = entry;
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 9b1ee22..84ef184 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -3384,7 +3384,7 @@ mips_parse_arguments (char *s, char float_format)
SKIP_SPACE_TABS (s);
}
mips_add_token (&token, OT_END);
- return (struct mips_operand_token *) obstack_finish (&mips_operand_tokens);
+ return obstack_finish (&mips_operand_tokens);
}
/* Return TRUE if opcode MO is valid on the currently selected ISA, ASE
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index f5740f8..6b8bde9 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -1886,15 +1886,13 @@ riscv_record_pcrel_fixup (htab_t p, const asection *sec, bfd_vma address,
symbolS *symbol, bfd_vma target)
{
riscv_pcrel_hi_fixup entry = {sec, address, symbol, target};
- riscv_pcrel_hi_fixup **slot =
- (riscv_pcrel_hi_fixup **) htab_find_slot (p, &entry, INSERT);
+ void **slot = htab_find_slot (p, &entry, INSERT);
if (slot == NULL)
return false;
- *slot = (riscv_pcrel_hi_fixup *) xmalloc (sizeof (riscv_pcrel_hi_fixup));
- if (*slot == NULL)
- return false;
- **slot = entry;
+ riscv_pcrel_hi_fixup *pent = xmalloc (sizeof (*pent));
+ *slot = pent;
+ *pent = entry;
return true;
}
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index 040e397..9afda6b 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -2522,7 +2522,7 @@ xg_translate_idioms (char **popname, int *pnum_args, char **arg_strings)
{
if (*pnum_args == 0)
{
- arg_strings[0] = (char *) xmalloc (2);
+ arg_strings[0] = xmalloc (2);
strcpy (arg_strings[0], "0");
*pnum_args = 1;
}
diff --git a/gas/ecoff.c b/gas/ecoff.c
index 27724bb..235bb80 100644
--- a/gas/ecoff.c
+++ b/gas/ecoff.c
@@ -1524,7 +1524,7 @@ add_varray_page (varray_t *vp /* varray to add page to */)
#ifdef MALLOC_CHECK
if (vp->object_size > 1)
- new_links->datum = (page_type *) xcalloc (1, vp->object_size);
+ new_links->datum = xcalloc (1, vp->object_size);
else
#endif
new_links->datum = allocate_page ();
@@ -4715,7 +4715,7 @@ ecoff_build_debug (HDRR *hdr,
static page_type *
allocate_cluster (unsigned long npages)
{
- page_type *value = (page_type *) xmalloc (npages * PAGE_USIZE);
+ page_type *value = xmalloc (npages * PAGE_USIZE);
#ifdef ECOFF_DEBUG
if (debug > 3)
diff --git a/gas/frags.c b/gas/frags.c
index 59699ae..0ad1240 100644
--- a/gas/frags.c
+++ b/gas/frags.c
@@ -81,7 +81,7 @@ frag_alloc (struct obstack *ob, size_t extra)
(void) obstack_alloc (ob, 0);
oalign = obstack_alignment_mask (ob);
obstack_alignment_mask (ob) = 0;
- ptr = (fragS *) obstack_alloc (ob, extra + SIZEOF_STRUCT_FRAG);
+ ptr = obstack_alloc (ob, extra + SIZEOF_STRUCT_FRAG);
obstack_alignment_mask (ob) = oalign;
memset (ptr, 0, SIZEOF_STRUCT_FRAG);
totalfrags++;
diff --git a/gas/read.c b/gas/read.c
index 874802e..a00fa97 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -6348,7 +6348,7 @@ demand_copy_string (int *lenP)
/* JF this next line is so demand_copy_C_string will return a
null terminated string. */
obstack_1grow (&notes, '\0');
- retval = (char *) obstack_finish (&notes);
+ retval = obstack_finish (&notes);
}
else
{
@@ -6567,7 +6567,7 @@ s_include (int arg ATTRIBUTE_UNUSED)
}
obstack_1grow (&notes, '\0');
- filename = (char *) obstack_finish (&notes);
+ filename = obstack_finish (&notes);
while (!is_end_of_stmt (*input_line_pointer))
++input_line_pointer;
}
diff --git a/gas/subsegs.c b/gas/subsegs.c
index bc80c85..8a5f7ac 100644
--- a/gas/subsegs.c
+++ b/gas/subsegs.c
@@ -132,7 +132,7 @@ subseg_set_rest (segT seg, subsegT subseg)
{
/* This should be the only code that creates a frchainS. */
- newP = (frchainS *) obstack_alloc (&frchains, sizeof (frchainS));
+ newP = obstack_alloc (&frchains, sizeof (frchainS));
newP->frch_subseg = subseg;
newP->fix_root = NULL;
newP->fix_tail = NULL;
diff --git a/gas/write.c b/gas/write.c
index 93ec614..353b11c 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -142,7 +142,7 @@ fix_new_internal (fragS *frag, /* Which frag? */
n_fixups++;
- fixP = (fixS *) obstack_alloc (&notes, sizeof (fixS));
+ fixP = obstack_alloc (&notes, sizeof (fixS));
fixP->fx_frag = frag;
fixP->fx_where = where;