[binutils-gdb] Replace "if (x) free (x)" with "free (x)", gas
Alan Modra
amodra@sourceware.org
Thu May 21 01:25:50 GMT 2020
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9fbb53c7c8d54ec90dc308cfb50902b90900b946
commit 9fbb53c7c8d54ec90dc308cfb50902b90900b946
Author: Alan Modra <amodra@gmail.com>
Date: Wed May 20 22:49:01 2020 +0930
Replace "if (x) free (x)" with "free (x)", gas
* atof-generic.c: Replace "if (x) free (x)" with "free (x)"
throughout.
* config/obj-elf.c: Likewise.
* config/tc-aarch64.c: Likewise.
* config/tc-arm.c: Likewise.
* config/tc-m68k.c: Likewise.
* config/tc-nios2.c: Likewise.
* config/tc-tic30.c: Likewise.
* ecoff.c: Likewise.
* read.c: Likewise.
* stabs.c: Likewise.
* symbols.c: Likewise.
* testsuite/gas/all/test-gen.c: Likewise.
Diff:
---
gas/ChangeLog | 16 ++++++++++++++++
gas/atof-generic.c | 6 ++----
gas/config/obj-elf.c | 10 +++-------
gas/config/tc-aarch64.c | 6 ++----
gas/config/tc-arm.c | 9 +++------
gas/config/tc-m68k.c | 3 +--
gas/config/tc-nios2.c | 7 ++-----
gas/config/tc-tic30.c | 3 +--
gas/ecoff.c | 6 ++----
gas/read.c | 12 ++++--------
gas/stabs.c | 3 +--
gas/symbols.c | 6 ++----
gas/testsuite/gas/all/test-gen.c | 6 ++----
13 files changed, 41 insertions(+), 52 deletions(-)
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 05ba3e9ce6d..1ff090ab688 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,19 @@
+2020-05-21 Alan Modra <amodra@gmail.com>
+
+ * atof-generic.c: Replace "if (x) free (x)" with "free (x)"
+ throughout.
+ * config/obj-elf.c: Likewise.
+ * config/tc-aarch64.c: Likewise.
+ * config/tc-arm.c: Likewise.
+ * config/tc-m68k.c: Likewise.
+ * config/tc-nios2.c: Likewise.
+ * config/tc-tic30.c: Likewise.
+ * ecoff.c: Likewise.
+ * read.c: Likewise.
+ * stabs.c: Likewise.
+ * symbols.c: Likewise.
+ * testsuite/gas/all/test-gen.c: Likewise.
+
2020-05-20 Nelson Chu <nelson.chu@sifive.com>
* testsuite/gas/riscv/priv-reg-fail-read-only-01.s: Updated.
diff --git a/gas/atof-generic.c b/gas/atof-generic.c
index 6dfd61bb81d..96a12f7462e 100644
--- a/gas/atof-generic.c
+++ b/gas/atof-generic.c
@@ -611,10 +611,8 @@ atof_generic (/* return pointer to just AFTER number we read. */
/* Assert sign of the number we made is '+'. */
address_of_generic_floating_point_number->sign = digits_sign_char;
- if (temporary_binary_low)
- free (temporary_binary_low);
- if (power_binary_low)
- free (power_binary_low);
+ free (temporary_binary_low);
+ free (power_binary_low);
free (digits_binary_low);
}
return return_value;
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 4bdddc9056d..de22b5a1da8 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -2021,8 +2021,7 @@ elf_copy_symbol_attributes (symbolS *dest, symbolS *src)
}
else
{
- if (destelf->size != NULL)
- free (destelf->size);
+ free (destelf->size);
destelf->size = NULL;
}
S_SET_SIZE (dest, S_GET_SIZE (src));
@@ -2124,11 +2123,8 @@ obj_elf_size (int ignore ATTRIBUTE_UNUSED)
if (exp.X_op == O_constant)
{
S_SET_SIZE (sym, exp.X_add_number);
- if (symbol_get_obj (sym)->size)
- {
- xfree (symbol_get_obj (sym)->size);
- symbol_get_obj (sym)->size = NULL;
- }
+ xfree (symbol_get_obj (sym)->size);
+ symbol_get_obj (sym)->size = NULL;
}
else
{
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index da786ba5e9b..728fd10a4e2 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -8269,8 +8269,7 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg)
/* Free the allocated the struct aarch64_inst.
N.B. currently there are very limited number of fix-up types actually use
this field, so the impact on the performance should be minimal . */
- if (fixP->tc_fix_data.inst != NULL)
- free (fixP->tc_fix_data.inst);
+ free (fixP->tc_fix_data.inst);
return;
}
@@ -9557,8 +9556,7 @@ aarch64_elf_copy_symbol_attributes (symbolS *dest, symbolS *src)
}
else
{
- if (destelf->size != NULL)
- free (destelf->size);
+ free (destelf->size);
destelf->size = NULL;
}
S_SET_SIZE (dest, S_GET_SIZE (src));
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index bc0b3a4f6f5..a69300697f0 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -2899,8 +2899,7 @@ s_unreq (int a ATTRIBUTE_UNUSED)
hash_delete (arm_reg_hsh, name, FALSE);
free ((char *) reg->name);
- if (reg->neon)
- free (reg->neon);
+ free (reg->neon);
free (reg);
/* Also locate the all upper case and all lower case versions.
@@ -2915,8 +2914,7 @@ s_unreq (int a ATTRIBUTE_UNUSED)
{
hash_delete (arm_reg_hsh, nbuf, FALSE);
free ((char *) reg->name);
- if (reg->neon)
- free (reg->neon);
+ free (reg->neon);
free (reg);
}
@@ -2927,8 +2925,7 @@ s_unreq (int a ATTRIBUTE_UNUSED)
{
hash_delete (arm_reg_hsh, nbuf, FALSE);
free ((char *) reg->name);
- if (reg->neon)
- free (reg->neon);
+ free (reg->neon);
free (reg);
}
diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c
index 490df5dbf5f..cbb227a333d 100644
--- a/gas/config/tc-m68k.c
+++ b/gas/config/tc-m68k.c
@@ -6135,8 +6135,7 @@ pop_mri_control (void)
n = mri_control_stack;
mri_control_stack = n->outer;
- if (n->top != NULL)
- free (n->top);
+ free (n->top);
free (n->next);
free (n->bottom);
free (n);
diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c
index 52cfb985c15..aeca351ebad 100644
--- a/gas/config/tc-nios2.c
+++ b/gas/config/tc-nios2.c
@@ -3230,11 +3230,8 @@ nios2_insert_arg (char **parsed_args, const char *insert, int num,
static void
nios2_free_arg (char **parsed_args, int num ATTRIBUTE_UNUSED, int start)
{
- if (parsed_args[start])
- {
- free (parsed_args[start]);
- parsed_args[start] = NULL;
- }
+ free (parsed_args[start]);
+ parsed_args[start] = NULL;
}
/* This function swaps the pseudo-op for a real op. */
diff --git a/gas/config/tc-tic30.c b/gas/config/tc-tic30.c
index f1954d0d935..c31c7604275 100644
--- a/gas/config/tc-tic30.c
+++ b/gas/config/tc-tic30.c
@@ -1997,8 +1997,7 @@ md_assemble (char *line)
for (i = 0; i < insn.operands; i++)
{
- if (insn.operand_type[i]->immediate.label)
- free (insn.operand_type[i]->immediate.label);
+ free (insn.operand_type[i]->immediate.label);
free (insn.operand_type[i]);
}
}
diff --git a/gas/ecoff.c b/gas/ecoff.c
index 1163c3315fe..08bfee1fc5c 100644
--- a/gas/ecoff.c
+++ b/gas/ecoff.c
@@ -2526,10 +2526,8 @@ ecoff_directive_def (int ignore ATTRIBUTE_UNUSED)
as_warn (_("empty symbol name in .def; ignored"));
else
{
- if (coff_sym_name != (char *) NULL)
- free (coff_sym_name);
- if (coff_tag != (char *) NULL)
- free (coff_tag);
+ free (coff_sym_name);
+ free (coff_tag);
coff_sym_name = xstrdup (name);
coff_type = type_info_init;
diff --git a/gas/read.c b/gas/read.c
index cdb4b3a8189..8f93c2ba2b4 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -1332,8 +1332,7 @@ read_a_source_file (const char *name)
new_length += 100;
}
- if (tmp_buf)
- free (tmp_buf);
+ free (tmp_buf);
/* We've "scrubbed" input to the preferred format. In the
process we may have consumed the whole of the remaining
@@ -1801,8 +1800,7 @@ s_comm_internal (int param,
out:
if (flag_mri)
mri_comment_end (stop, stopc);
- if (name != NULL)
- free (name);
+ free (name);
return symbolP;
}
@@ -1862,8 +1860,7 @@ s_mri_common (int small ATTRIBUTE_UNUSED)
sym = symbol_find_or_make (name);
c = restore_line_pointer (c);
- if (alc != NULL)
- free (alc);
+ free (alc);
if (*input_line_pointer != ',')
align = 0;
@@ -5814,8 +5811,7 @@ s_incbin (int x ATTRIBUTE_UNUSED)
done:
if (binfile != NULL)
fclose (binfile);
- if (path)
- free (path);
+ free (path);
}
/* .include -- include a file at this point. */
diff --git a/gas/stabs.c b/gas/stabs.c
index de37f0ae937..c962bb4fdf7 100644
--- a/gas/stabs.c
+++ b/gas/stabs.c
@@ -564,8 +564,7 @@ generate_asm_file (int type, const char *file)
colon (sym);
- if (last_file != NULL)
- free (last_file);
+ free (last_file);
last_file = xstrdup (file);
free (buf);
diff --git a/gas/symbols.c b/gas/symbols.c
index 2fa75251738..acf394330df 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -923,14 +923,12 @@ symbol_find_noref (const char *name, int noref)
*copy++ = TOUPPER (c);
*copy = '\0';
- if (copy2 != NULL)
- free (copy2);
+ free (copy2);
copy = (char *) name;
}
result = symbol_find_exact_noref (name, noref);
- if (copy != NULL)
- free (copy);
+ free (copy);
return result;
}
diff --git a/gas/testsuite/gas/all/test-gen.c b/gas/testsuite/gas/all/test-gen.c
index 11143ad132e..f2e0bfec26e 100644
--- a/gas/testsuite/gas/all/test-gen.c
+++ b/gas/testsuite/gas/all/test-gen.c
@@ -711,10 +711,8 @@ output_insns (func **insn, FILE *as_in, FILE *dis_out)
for (; part-- > 0;)
{
skip:
- if (data[part].as_in)
- free (data[part].as_in);
- if (data[part].dis_out
- && data[part].dis_out != data[part].as_in)
+ free (data[part].as_in);
+ if (data[part].dis_out != data[part].as_in)
free (data[part].dis_out);
}
More information about the Binutils-cvs
mailing list