aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog23
-rw-r--r--bfd/aoutx.h46
-rw-r--r--bfd/archive.c18
-rw-r--r--bfd/bfd.c3
-rw-r--r--bfd/bfdio.c3
-rw-r--r--bfd/coff-alpha.c9
-rw-r--r--bfd/coff-ppc.c95
-rw-r--r--bfd/coff-sh.c17
-rw-r--r--bfd/coff-stgo32.c3
-rw-r--r--bfd/coffcode.h3
-rw-r--r--bfd/coffgen.c13
-rw-r--r--bfd/cofflink.c98
-rw-r--r--bfd/cpu-arm.c6
-rw-r--r--bfd/doc/chew.c9
-rw-r--r--bfd/dwarf2.c43
-rw-r--r--bfd/ecoff.c63
-rw-r--r--bfd/ecofflink.c17
-rw-r--r--bfd/elf-eh-frame.c19
-rw-r--r--bfd/elf-m10200.c27
-rw-r--r--bfd/elf-m10300.c33
-rw-r--r--bfd/elf-strtab.c3
-rw-r--r--bfd/elf.c18
-rw-r--r--bfd/elf32-arc.c12
-rw-r--r--bfd/elf32-arm.c28
-rw-r--r--bfd/elf32-avr.c33
-rw-r--r--bfd/elf32-bfin.c10
-rw-r--r--bfd/elf32-cr16.c44
-rw-r--r--bfd/elf32-crx.c27
-rw-r--r--bfd/elf32-epiphany.c12
-rw-r--r--bfd/elf32-ft32.c6
-rw-r--r--bfd/elf32-h8300.c27
-rw-r--r--bfd/elf32-ip2k.c15
-rw-r--r--bfd/elf32-m32c.c18
-rw-r--r--bfd/elf32-m68hc11.c16
-rw-r--r--bfd/elf32-m68k.c10
-rw-r--r--bfd/elf32-microblaze.c22
-rw-r--r--bfd/elf32-msp430.c11
-rw-r--r--bfd/elf32-nds32.c20
-rw-r--r--bfd/elf32-nios2.c3
-rw-r--r--bfd/elf32-ppc.c23
-rw-r--r--bfd/elf32-pru.c11
-rw-r--r--bfd/elf32-rl78.c10
-rw-r--r--bfd/elf32-rx.c6
-rw-r--r--bfd/elf32-sh.c42
-rw-r--r--bfd/elf32-spu.c15
-rw-r--r--bfd/elf32-v850.c9
-rw-r--r--bfd/elf32-xtensa.c46
-rw-r--r--bfd/elf64-alpha.c51
-rw-r--r--bfd/elf64-hppa.c3
-rw-r--r--bfd/elf64-ia64-vms.c44
-rw-r--r--bfd/elf64-mips.c7
-rw-r--r--bfd/elf64-mmix.c8
-rw-r--r--bfd/elf64-ppc.c56
-rw-r--r--bfd/elf64-sparc.c7
-rw-r--r--bfd/elfcode.h19
-rw-r--r--bfd/elflink.c107
-rw-r--r--bfd/elfnn-ia64.c37
-rw-r--r--bfd/elfnn-riscv.c5
-rw-r--r--bfd/elfxx-mips.c85
-rw-r--r--bfd/elfxx-x86.c3
-rw-r--r--bfd/format.c8
-rw-r--r--bfd/ihex.c20
-rw-r--r--bfd/libbfd.c2
-rw-r--r--bfd/linker.c12
-rw-r--r--bfd/mmo.c3
-rw-r--r--bfd/opncls.c9
-rw-r--r--bfd/pdp11.c45
-rw-r--r--bfd/peXXigen.c30
-rw-r--r--bfd/pef.c26
-rw-r--r--bfd/peicode.h6
-rw-r--r--bfd/simple.c5
-rw-r--r--bfd/som.c84
-rw-r--r--bfd/srec.c33
-rw-r--r--bfd/stabs.c9
-rw-r--r--bfd/syms.c12
-rw-r--r--bfd/targets.c3
-rw-r--r--bfd/vms-lib.c9
-rw-r--r--bfd/xcofflink.c106
-rw-r--r--bfd/xtensa-isa.c43
79 files changed, 657 insertions, 1285 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b3dabb3..bc51d86 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,26 @@
+2020-05-21 Alan Modra <amodra@gmail.com>
+
+ * aoutx.h: Replace "if (x) free (x)" with "free (x)" throughout.
+ * archive.c, * bfd.c, * bfdio.c, * coff-alpha.c, * coff-ppc.c,
+ * coff-sh.c, * coff-stgo32.c, * coffcode.h, * coffgen.c,
+ * cofflink.c, * cpu-arm.c, * doc/chew.c, * dwarf2.c, * ecoff.c,
+ * ecofflink.c, * elf-eh-frame.c, * elf-m10200.c, * elf-m10300.c,
+ * elf-strtab.c, * elf.c, * elf32-arc.c, * elf32-arm.c,
+ * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c, * elf32-crx.c,
+ * elf32-epiphany.c, * elf32-ft32.c, * elf32-h8300.c,
+ * elf32-ip2k.c, * elf32-m32c.c, * elf32-m68hc11.c,
+ * elf32-m68k.c, * elf32-microblaze.c, * elf32-msp430.c,
+ * elf32-nds32.c, * elf32-nios2.c, * elf32-ppc.c, * elf32-pru.c,
+ * elf32-rl78.c, * elf32-rx.c, * elf32-sh.c, * elf32-spu.c,
+ * elf32-v850.c, * elf32-xtensa.c, * elf64-alpha.c,
+ * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mips.c
+ * elf64-mmix.c, * elf64-ppc.c, * elf64-sparc.c, * elfcode.h,
+ * elflink.c, * elfnn-ia64.c, * elfnn-riscv.c, * elfxx-mips.c,
+ * elfxx-x86.c, * format.c, * ihex.c, * libbfd.c, * linker.c,
+ * mmo.c, * opncls.c, * pdp11.c, * peXXigen.c, * pef.c,
+ * peicode.h, * simple.c, * som.c, * srec.c, * stabs.c, * syms.c,
+ * targets.c, * vms-lib.c, * xcofflink.c, * xtensa-isa.c: Likewise.
+
2020-05-20 Nelson Chu <nelson.chu@sifive.com>
* elfxx-riscv.h (riscv_parse_subset_t): Add new callback function
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 4cf5713..08083c1 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -2816,8 +2816,7 @@ NAME (aout, find_nearest_line) (bfd *abfd,
else
funclen = strlen (bfd_asymbol_name (func));
- if (adata (abfd).line_buf != NULL)
- free (adata (abfd).line_buf);
+ free (adata (abfd).line_buf);
if (filelen + funclen == 0)
adata (abfd).line_buf = buf = NULL;
@@ -2899,7 +2898,7 @@ NAME (aout, bfd_free_cached_info) (bfd *abfd)
|| abfd->tdata.aout_data == NULL)
return TRUE;
-#define BFCI_FREE(x) if (x != NULL) { free (x); x = NULL; }
+#define BFCI_FREE(x) do { free (x); x = NULL; } while (0)
BFCI_FREE (obj_aout_symbols (abfd));
#ifdef USE_MMAP
obj_aout_external_syms (abfd) = 0;
@@ -5617,26 +5616,15 @@ NAME (aout, final_link) (bfd *abfd,
}
}
- if (aout_info.contents != NULL)
- {
- free (aout_info.contents);
- aout_info.contents = NULL;
- }
- if (aout_info.relocs != NULL)
- {
- free (aout_info.relocs);
- aout_info.relocs = NULL;
- }
- if (aout_info.symbol_map != NULL)
- {
- free (aout_info.symbol_map);
- aout_info.symbol_map = NULL;
- }
- if (aout_info.output_syms != NULL)
- {
- free (aout_info.output_syms);
- aout_info.output_syms = NULL;
- }
+ free (aout_info.contents);
+ aout_info.contents = NULL;
+ free (aout_info.relocs);
+ aout_info.relocs = NULL;
+ free (aout_info.symbol_map);
+ aout_info.symbol_map = NULL;
+ free (aout_info.output_syms);
+ aout_info.output_syms = NULL;
+
if (includes_hash_initialized)
{
bfd_hash_table_free (&aout_info.includes.root);
@@ -5679,14 +5667,10 @@ NAME (aout, final_link) (bfd *abfd,
return TRUE;
error_return:
- if (aout_info.contents != NULL)
- free (aout_info.contents);
- if (aout_info.relocs != NULL)
- free (aout_info.relocs);
- if (aout_info.symbol_map != NULL)
- free (aout_info.symbol_map);
- if (aout_info.output_syms != NULL)
- free (aout_info.output_syms);
+ free (aout_info.contents);
+ free (aout_info.relocs);
+ free (aout_info.symbol_map);
+ free (aout_info.output_syms);
if (includes_hash_initialized)
bfd_hash_table_free (&aout_info.includes.root);
return FALSE;
diff --git a/bfd/archive.c b/bfd/archive.c
index 1322977..9d63849 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -1468,8 +1468,7 @@ adjust_relative_path (const char * path, const char * ref_path)
if (len > pathbuf_len)
{
- if (pathbuf != NULL)
- free (pathbuf);
+ free (pathbuf);
pathbuf_len = 0;
pathbuf = (char *) bfd_malloc (len);
if (pathbuf == NULL)
@@ -2326,8 +2325,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
{
if (storage > syms_max)
{
- if (syms_max > 0)
- free (syms);
+ free (syms);
syms_max = storage;
syms = (asymbol **) bfd_malloc (syms_max);
if (syms == NULL)
@@ -2408,20 +2406,16 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
ret = BFD_SEND (arch, write_armap,
(arch, elength, map, orl_count, stridx));
- if (syms_max > 0)
- free (syms);
- if (map != NULL)
- free (map);
+ free (syms);
+ free (map);
if (first_name != NULL)
bfd_release (arch, first_name);
return ret;
error_return:
- if (syms_max > 0)
- free (syms);
- if (map != NULL)
- free (map);
+ free (syms);
+ free (map);
if (first_name != NULL)
bfd_release (arch, first_name);
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 84e74a3..538bdfa 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2487,8 +2487,7 @@ bfd_demangle (bfd *abfd, const char *name, int options)
res = cplus_demangle (name, options);
- if (alloc != NULL)
- free (alloc);
+ free (alloc);
if (res == NULL)
{
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 0133b76..5ef3ec4 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -662,8 +662,7 @@ memory_bclose (struct bfd *abfd)
{
struct bfd_in_memory *bim = (struct bfd_in_memory *) abfd->iostream;
- if (bim->buffer != NULL)
- free (bim->buffer);
+ free (bim->buffer);
free (bim);
abfd->iostream = NULL;
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index 4fd3b5c..cb52668 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -1127,13 +1127,11 @@ alpha_ecoff_get_relocated_section_contents (bfd *abfd,
abort ();
successful_return:
- if (reloc_vector != NULL)
- free (reloc_vector);
+ free (reloc_vector);
return data;
error_return:
- if (reloc_vector != NULL)
- free (reloc_vector);
+ free (reloc_vector);
return NULL;
}
@@ -2171,8 +2169,7 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos)
return nbfd;
error_return:
- if (buf != NULL)
- free (buf);
+ free (buf);
if (nbfd != NULL)
bfd_close (nbfd);
return NULL;
diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c
index bc7118f..a3ad1ef 100644
--- a/bfd/coff-ppc.c
+++ b/bfd/coff-ppc.c
@@ -2258,41 +2258,20 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
coff_debug_merge_hash_table_free (&flaginfo.debug_merge);
debug_merge_allocated = FALSE;
- if (flaginfo.internal_syms != NULL)
- {
- free (flaginfo.internal_syms);
- flaginfo.internal_syms = NULL;
- }
- if (flaginfo.sec_ptrs != NULL)
- {
- free (flaginfo.sec_ptrs);
- flaginfo.sec_ptrs = NULL;
- }
- if (flaginfo.sym_indices != NULL)
- {
- free (flaginfo.sym_indices);
- flaginfo.sym_indices = NULL;
- }
- if (flaginfo.linenos != NULL)
- {
- free (flaginfo.linenos);
- flaginfo.linenos = NULL;
- }
- if (flaginfo.contents != NULL)
- {
- free (flaginfo.contents);
- flaginfo.contents = NULL;
- }
- if (flaginfo.external_relocs != NULL)
- {
- free (flaginfo.external_relocs);
- flaginfo.external_relocs = NULL;
- }
- if (flaginfo.internal_relocs != NULL)
- {
- free (flaginfo.internal_relocs);
- flaginfo.internal_relocs = NULL;
- }
+ free (flaginfo.internal_syms);
+ flaginfo.internal_syms = NULL;
+ free (flaginfo.sec_ptrs);
+ flaginfo.sec_ptrs = NULL;
+ free (flaginfo.sym_indices);
+ flaginfo.sym_indices = NULL;
+ free (flaginfo.linenos);
+ flaginfo.linenos = NULL;
+ free (flaginfo.contents);
+ flaginfo.contents = NULL;
+ free (flaginfo.external_relocs);
+ flaginfo.external_relocs = NULL;
+ free (flaginfo.internal_relocs);
+ flaginfo.internal_relocs = NULL;
/* The value of the last C_FILE symbol is supposed to be the symbol
index of the first external symbol. Write it out again if
@@ -2318,11 +2297,8 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
goto error_return;
/* The outsyms buffer is used by _bfd_coff_write_global_sym. */
- if (flaginfo.outsyms != NULL)
- {
- free (flaginfo.outsyms);
- flaginfo.outsyms = NULL;
- }
+ free (flaginfo.outsyms);
+ flaginfo.outsyms = NULL;
if (bfd_link_relocatable (info))
{
@@ -2375,10 +2351,8 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
for (i = 0; i < abfd->section_count; i++)
{
- if (flaginfo.section_info[i].relocs != NULL)
- free (flaginfo.section_info[i].relocs);
- if (flaginfo.section_info[i].rel_hashes != NULL)
- free (flaginfo.section_info[i].rel_hashes);
+ free (flaginfo.section_info[i].relocs);
+ free (flaginfo.section_info[i].rel_hashes);
}
free (flaginfo.section_info);
flaginfo.section_info = NULL;
@@ -2435,31 +2409,20 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
for (i = 0; i < abfd->section_count; i++)
{
- if (flaginfo.section_info[i].relocs != NULL)
- free (flaginfo.section_info[i].relocs);
- if (flaginfo.section_info[i].rel_hashes != NULL)
- free (flaginfo.section_info[i].rel_hashes);
+ free (flaginfo.section_info[i].relocs);
+ free (flaginfo.section_info[i].rel_hashes);
}
free (flaginfo.section_info);
}
- if (flaginfo.internal_syms != NULL)
- free (flaginfo.internal_syms);
- if (flaginfo.sec_ptrs != NULL)
- free (flaginfo.sec_ptrs);
- if (flaginfo.sym_indices != NULL)
- free (flaginfo.sym_indices);
- if (flaginfo.outsyms != NULL)
- free (flaginfo.outsyms);
- if (flaginfo.linenos != NULL)
- free (flaginfo.linenos);
- if (flaginfo.contents != NULL)
- free (flaginfo.contents);
- if (flaginfo.external_relocs != NULL)
- free (flaginfo.external_relocs);
- if (flaginfo.internal_relocs != NULL)
- free (flaginfo.internal_relocs);
- if (external_relocs != NULL)
- free (external_relocs);
+ free (flaginfo.internal_syms);
+ free (flaginfo.sec_ptrs);
+ free (flaginfo.sym_indices);
+ free (flaginfo.outsyms);
+ free (flaginfo.linenos);
+ free (flaginfo.contents);
+ free (flaginfo.external_relocs);
+ free (flaginfo.internal_relocs);
+ free (external_relocs);
return FALSE;
}
#endif
diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c
index b46a5e3..0c10611 100644
--- a/bfd/coff-sh.c
+++ b/bfd/coff-sh.c
@@ -1056,10 +1056,9 @@ sh_relax_section (bfd *abfd,
return TRUE;
error_return:
- if (internal_relocs != NULL
- && internal_relocs != coff_section_data (abfd, sec)->relocs)
+ if (internal_relocs != coff_section_data (abfd, sec)->relocs)
free (internal_relocs);
- if (contents != NULL && contents != coff_section_data (abfd, sec)->contents)
+ if (contents != coff_section_data (abfd, sec)->contents)
free (contents);
return FALSE;
}
@@ -2723,8 +2722,7 @@ sh_align_loads (bfd *abfd,
return TRUE;
error_return:
- if (labels != NULL)
- free (labels);
+ free (labels);
return FALSE;
}
@@ -2995,12 +2993,9 @@ sh_coff_get_relocated_section_contents (bfd *output_bfd,
return data;
error_return:
- if (internal_relocs != NULL)
- free (internal_relocs);
- if (internal_syms != NULL)
- free (internal_syms);
- if (sections != NULL)
- free (sections);
+ free (internal_relocs);
+ free (internal_syms);
+ free (sections);
return NULL;
}
diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c
index 0fea119..b5e893d 100644
--- a/bfd/coff-stgo32.c
+++ b/bfd/coff-stgo32.c
@@ -249,8 +249,7 @@ go32exe_cleanup (bfd *abfd)
{
abfd->origin = 0;
- if (go32exe_temp_stub != NULL)
- free (go32exe_temp_stub);
+ free (go32exe_temp_stub);
go32exe_temp_stub = NULL;
go32exe_temp_stub_size = 0;
}
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index c6569ec..9a97ba7 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -2666,8 +2666,7 @@ coff_write_relocs (bfd * abfd, int first_undef)
}
#ifdef TARG_AUX
- if (p != NULL)
- free (p);
+ free (p);
#endif
}
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 96140e0..94589b4 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -544,11 +544,8 @@ _bfd_coff_read_internal_relocs (bfd *abfd,
for (; erel < erel_end; erel += relsz, irel++)
bfd_coff_swap_reloc_in (abfd, (void *) erel, (void *) irel);
- if (free_external != NULL)
- {
- free (free_external);
- free_external = NULL;
- }
+ free (free_external);
+ free_external = NULL;
if (cache && free_internal != NULL)
{
@@ -566,10 +563,8 @@ _bfd_coff_read_internal_relocs (bfd *abfd,
return internal_relocs;
error_return:
- if (free_external != NULL)
- free (free_external);
- if (free_internal != NULL)
- free (free_internal);
+ free (free_external);
+ free (free_internal);
return NULL;
}
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index 0beff83..27ac20e 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -993,41 +993,20 @@ _bfd_coff_final_link (bfd *abfd,
coff_debug_merge_hash_table_free (&flaginfo.debug_merge);
debug_merge_allocated = FALSE;
- if (flaginfo.internal_syms != NULL)
- {
- free (flaginfo.internal_syms);
- flaginfo.internal_syms = NULL;
- }
- if (flaginfo.sec_ptrs != NULL)
- {
- free (flaginfo.sec_ptrs);
- flaginfo.sec_ptrs = NULL;
- }
- if (flaginfo.sym_indices != NULL)
- {
- free (flaginfo.sym_indices);
- flaginfo.sym_indices = NULL;
- }
- if (flaginfo.linenos != NULL)
- {
- free (flaginfo.linenos);
- flaginfo.linenos = NULL;
- }
- if (flaginfo.contents != NULL)
- {
- free (flaginfo.contents);
- flaginfo.contents = NULL;
- }
- if (flaginfo.external_relocs != NULL)
- {
- free (flaginfo.external_relocs);
- flaginfo.external_relocs = NULL;
- }
- if (flaginfo.internal_relocs != NULL)
- {
- free (flaginfo.internal_relocs);
- flaginfo.internal_relocs = NULL;
- }
+ free (flaginfo.internal_syms);
+ flaginfo.internal_syms = NULL;
+ free (flaginfo.sec_ptrs);
+ flaginfo.sec_ptrs = NULL;
+ free (flaginfo.sym_indices);
+ flaginfo.sym_indices = NULL;
+ free (flaginfo.linenos);
+ flaginfo.linenos = NULL;
+ free (flaginfo.contents);
+ flaginfo.contents = NULL;
+ free (flaginfo.external_relocs);
+ flaginfo.external_relocs = NULL;
+ free (flaginfo.internal_relocs);
+ flaginfo.internal_relocs = NULL;
/* The value of the last C_FILE symbol is supposed to be the symbol
index of the first external symbol. Write it out again if
@@ -1066,11 +1045,8 @@ _bfd_coff_final_link (bfd *abfd,
goto error_return;
/* The outsyms buffer is used by _bfd_coff_write_global_sym. */
- if (flaginfo.outsyms != NULL)
- {
- free (flaginfo.outsyms);
- flaginfo.outsyms = NULL;
- }
+ free (flaginfo.outsyms);
+ flaginfo.outsyms = NULL;
if (bfd_link_relocatable (info) && max_output_reloc_count > 0)
{
@@ -1141,10 +1117,8 @@ _bfd_coff_final_link (bfd *abfd,
for (i = 0; i < abfd->section_count; i++)
{
- if (flaginfo.section_info[i].relocs != NULL)
- free (flaginfo.section_info[i].relocs);
- if (flaginfo.section_info[i].rel_hashes != NULL)
- free (flaginfo.section_info[i].rel_hashes);
+ free (flaginfo.section_info[i].relocs);
+ free (flaginfo.section_info[i].rel_hashes);
}
free (flaginfo.section_info);
flaginfo.section_info = NULL;
@@ -1203,31 +1177,20 @@ _bfd_coff_final_link (bfd *abfd,
for (i = 0; i < abfd->section_count; i++)
{
- if (flaginfo.section_info[i].relocs != NULL)
- free (flaginfo.section_info[i].relocs);
- if (flaginfo.section_info[i].rel_hashes != NULL)
- free (flaginfo.section_info[i].rel_hashes);
+ free (flaginfo.section_info[i].relocs);
+ free (flaginfo.section_info[i].rel_hashes);
}
free (flaginfo.section_info);
}
- if (flaginfo.internal_syms != NULL)
- free (flaginfo.internal_syms);
- if (flaginfo.sec_ptrs != NULL)
- free (flaginfo.sec_ptrs);
- if (flaginfo.sym_indices != NULL)
- free (flaginfo.sym_indices);
- if (flaginfo.outsyms != NULL)
- free (flaginfo.outsyms);
- if (flaginfo.linenos != NULL)
- free (flaginfo.linenos);
- if (flaginfo.contents != NULL)
- free (flaginfo.contents);
- if (flaginfo.external_relocs != NULL)
- free (flaginfo.external_relocs);
- if (flaginfo.internal_relocs != NULL)
- free (flaginfo.internal_relocs);
- if (external_relocs != NULL)
- free (external_relocs);
+ free (flaginfo.internal_syms);
+ free (flaginfo.sec_ptrs);
+ free (flaginfo.sym_indices);
+ free (flaginfo.outsyms);
+ free (flaginfo.linenos);
+ free (flaginfo.contents);
+ free (flaginfo.external_relocs);
+ free (flaginfo.internal_relocs);
+ free (external_relocs);
return FALSE;
}
@@ -1286,8 +1249,7 @@ process_embedded_commands (bfd *output_bfd,
if (!bfd_malloc_and_get_section (abfd, sec, &copy))
{
- if (copy != NULL)
- free (copy);
+ free (copy);
return 0;
}
e = (char *) copy + sec->size;
diff --git a/bfd/cpu-arm.c b/bfd/cpu-arm.c
index 903ad84..0b7a8c4 100644
--- a/bfd/cpu-arm.c
+++ b/bfd/cpu-arm.c
@@ -458,8 +458,7 @@ bfd_arm_update_notes (bfd *abfd, const char *note_section)
return TRUE;
FAIL:
- if (buffer != NULL)
- free (buffer);
+ free (buffer);
return FALSE;
}
@@ -528,8 +527,7 @@ bfd_arm_get_mach_from_notes (bfd *abfd, const char *note_section)
}
FAIL:
- if (buffer != NULL)
- free (buffer);
+ free (buffer);
return bfd_mach_arm_unknown;
}
diff --git a/bfd/doc/chew.c b/bfd/doc/chew.c
index 31e3e3b..76cb09f 100644
--- a/bfd/doc/chew.c
+++ b/bfd/doc/chew.c
@@ -170,8 +170,7 @@ static void
delete_string (buffer)
string_type *buffer;
{
- if (buffer->ptr)
- free (buffer->ptr);
+ free (buffer->ptr);
buffer->ptr = NULL;
}
@@ -1258,8 +1257,7 @@ free_words (void)
{
dict_type *next;
- if (ptr->word)
- free (ptr->word);
+ free (ptr->word);
if (ptr->code)
{
int i;
@@ -1443,8 +1441,7 @@ compile (string)
fprintf (stderr, "syntax error at %s\n", string - 1);
}
}
- if (word)
- free (word);
+ free (word);
}
static void
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 48b1bdc..9ed4a4a 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -2420,8 +2420,7 @@ decode_line_info (struct comp_unit *unit)
(_("DWARF error: mangled line number section"));
bfd_set_error (bfd_error_bad_value);
line_fail:
- if (filename != NULL)
- free (filename);
+ free (filename);
goto fail;
}
break;
@@ -2466,8 +2465,7 @@ decode_line_info (struct comp_unit *unit)
filenum = _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read,
FALSE, line_end);
line_ptr += bytes_read;
- if (filename)
- free (filename);
+ free (filename);
filename = concat_filename (table, filenum);
break;
}
@@ -2513,8 +2511,7 @@ decode_line_info (struct comp_unit *unit)
}
}
- if (filename)
- free (filename);
+ free (filename);
}
if (unit->line_offset == 0)
@@ -2529,10 +2526,8 @@ decode_line_info (struct comp_unit *unit)
table->sequences = table->sequences->prev_sequence;
free (seq);
}
- if (table->files != NULL)
- free (table->files);
- if (table->dirs != NULL)
- free (table->dirs);
+ free (table->files);
+ free (table->dirs);
return NULL;
}
@@ -5146,34 +5141,22 @@ _bfd_dwarf2_cleanup_debug_info (bfd *abfd, void **pinfo)
free (each->line_table->dirs);
}
- if (each->lookup_funcinfo_table)
- {
- free (each->lookup_funcinfo_table);
- each->lookup_funcinfo_table = NULL;
- }
+ free (each->lookup_funcinfo_table);
+ each->lookup_funcinfo_table = NULL;
while (function_table)
{
- if (function_table->file)
- {
- free (function_table->file);
- function_table->file = NULL;
- }
- if (function_table->caller_file)
- {
- free (function_table->caller_file);
- function_table->caller_file = NULL;
- }
+ free (function_table->file);
+ function_table->file = NULL;
+ free (function_table->caller_file);
+ function_table->caller_file = NULL;
function_table = function_table->prev_func;
}
while (variable_table)
{
- if (variable_table->file)
- {
- free (variable_table->file);
- variable_table->file = NULL;
- }
+ free (variable_table->file);
+ variable_table->file = NULL;
variable_table = variable_table->prev_var;
}
}
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 1b0d423..dcded6f 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -488,12 +488,10 @@ ecoff_slurp_symbolic_header (bfd *abfd)
/* Now we can get the correct number of symbols. */
abfd->symcount = internal_symhdr->isymMax + internal_symhdr->iextMax;
- if (raw != NULL)
- free (raw);
+ free (raw);
return TRUE;
error_return:
- if (raw != NULL)
- free (raw);
+ free (raw);
return FALSE;
}
@@ -2797,14 +2795,12 @@ _bfd_ecoff_write_object_contents (bfd *abfd)
if (reloc_buff != NULL)
bfd_release (abfd, reloc_buff);
- if (buff != NULL)
- free (buff);
+ free (buff);
return TRUE;
error_return:
if (reloc_buff != NULL)
bfd_release (abfd, reloc_buff);
- if (buff != NULL)
- free (buff);
+ free (buff);
return FALSE;
}
@@ -3528,17 +3524,13 @@ ecoff_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
result = ecoff_link_add_externals (abfd, info, external_ext, ssext);
- if (ssext != NULL)
- free (ssext);
- if (external_ext != NULL)
- free (external_ext);
+ free (ssext);
+ free (external_ext);
return result;
error_return:
- if (ssext != NULL)
- free (ssext);
- if (external_ext != NULL)
- free (external_ext);
+ free (ssext);
+ free (external_ext);
return FALSE;
}
@@ -3820,24 +3812,15 @@ ecoff_final_link_debug_accumulate (bfd *output_bfd,
return_something:
if (ecoff_data (input_bfd)->raw_syments == NULL)
{
- if (debug->line != NULL)
- free (debug->line);
- if (debug->external_dnr != NULL)
- free (debug->external_dnr);
- if (debug->external_pdr != NULL)
- free (debug->external_pdr);
- if (debug->external_sym != NULL)
- free (debug->external_sym);
- if (debug->external_opt != NULL)
- free (debug->external_opt);
- if (debug->external_aux != NULL)
- free (debug->external_aux);
- if (debug->ss != NULL)
- free (debug->ss);
- if (debug->external_fdr != NULL)
- free (debug->external_fdr);
- if (debug->external_rfd != NULL)
- free (debug->external_rfd);
+ free (debug->line);
+ free (debug->external_dnr);
+ free (debug->external_pdr);
+ free (debug->external_sym);
+ free (debug->external_opt);
+ free (debug->external_aux);
+ free (debug->ss);
+ free (debug->external_fdr);
+ free (debug->external_rfd);
/* Make sure we don't accidentally follow one of these pointers
into freed memory. */
@@ -3926,17 +3909,13 @@ ecoff_indirect_link_order (bfd *output_bfd,
output_section->reloc_count += input_section->reloc_count;
}
- if (contents != NULL)
- free (contents);
- if (external_relocs != NULL)
- free (external_relocs);
+ free (contents);
+ free (external_relocs);
return TRUE;
error_return:
- if (contents != NULL)
- free (contents);
- if (external_relocs != NULL)
- free (external_relocs);
+ free (contents);
+ free (external_relocs);
return FALSE;
}
diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c
index dde5593..e7b35f6 100644
--- a/bfd/ecofflink.c
+++ b/bfd/ecofflink.c
@@ -1464,12 +1464,10 @@ ecoff_write_symhdr (bfd *abfd,
!= swap->external_hdr_size)
goto error_return;
- if (buff != NULL)
- free (buff);
+ free (buff);
return TRUE;
error_return:
- if (buff != NULL)
- free (buff);
+ free (buff);
return FALSE;
}
@@ -1685,13 +1683,11 @@ bfd_ecoff_write_accumulated_debug (void * handle,
if (bfd_bwrite (debug->external_ext, amt, abfd) != amt)
goto error_return;
- if (space != NULL)
- free (space);
+ free (space);
return TRUE;
error_return:
- if (space != NULL)
- free (space);
+ free (space);
return FALSE;
}
@@ -2320,12 +2316,11 @@ lookup_line (bfd *abfd,
if (len != 0)
{
- if (line_info->find_buffer != NULL)
- free (line_info->find_buffer);
+ free (line_info->find_buffer);
buffer = (char *) bfd_malloc ((bfd_size_type) len);
+ line_info->find_buffer = buffer;
if (buffer == NULL)
return FALSE;
- line_info->find_buffer = buffer;
}
if (function_name != NULL)
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index 3cf82d5..7a129b0 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -1049,13 +1049,10 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
(_("error in %pB(%pA); no .eh_frame_hdr table will be created"),
abfd, sec);
hdr_info->u.dwarf.table = FALSE;
- if (sec_info)
- free (sec_info);
+ free (sec_info);
success:
- if (ehbuf)
- free (ehbuf);
- if (local_cies)
- free (local_cies);
+ free (ehbuf);
+ free (local_cies);
#undef REQUIRE
}
@@ -1558,11 +1555,8 @@ _bfd_elf_discard_section_eh_frame
}
}
- if (sec_info->cies)
- {
- free (sec_info->cies);
- sec_info->cies = NULL;
- }
+ free (sec_info->cies);
+ sec_info->cies = NULL;
/* It may be that some .eh_frame input section has greater alignment
than other .eh_frame sections. In that case we run the risk of
@@ -2511,8 +2505,7 @@ write_dwarf_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info)
retval = FALSE;
free (contents);
- if (hdr_info->u.dwarf.array != NULL)
- free (hdr_info->u.dwarf.array);
+ free (hdr_info->u.dwarf.array);
return retval;
}
diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c
index 0c8767e..58c1515 100644
--- a/bfd/elf-m10200.c
+++ b/bfd/elf-m10200.c
@@ -1207,21 +1207,17 @@ mn10200_elf_relax_section (bfd *abfd,
}
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
@@ -1355,10 +1351,8 @@ mn10200_elf_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections))
goto error_return;
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
@@ -1367,13 +1361,10 @@ mn10200_elf_get_relocated_section_contents (bfd *output_bfd,
return data;
error_return:
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (input_section)->relocs != internal_relocs)
+ if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
return NULL;
}
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index b15af60..696514a 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -1372,7 +1372,7 @@ mn10300_elf_check_relocs (bfd *abfd,
result = TRUE;
fail:
- if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
return result;
@@ -2912,8 +2912,7 @@ mn10300_elf_relax_section (bfd *abfd,
}
/* Cache or free any memory we allocated for the relocs. */
- if (internal_relocs != NULL
- && elf_section_data (section)->relocs != internal_relocs)
+ if (elf_section_data (section)->relocs != internal_relocs)
free (internal_relocs);
internal_relocs = NULL;
@@ -3222,8 +3221,7 @@ mn10300_elf_relax_section (bfd *abfd,
}
/* Cache or free any memory we allocated for the relocs. */
- if (internal_relocs != NULL
- && elf_section_data (section)->relocs != internal_relocs)
+ if (elf_section_data (section)->relocs != internal_relocs)
free (internal_relocs);
internal_relocs = NULL;
@@ -4391,21 +4389,17 @@ mn10300_elf_relax_section (bfd *abfd,
}
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (section)->this_hdr.contents != contents)
+ if (elf_section_data (section)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (section)->relocs != internal_relocs)
+ if (elf_section_data (section)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
@@ -4494,9 +4488,8 @@ mn10300_elf_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections))
goto error_return;
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
if (internal_relocs != elf_section_data (input_section)->relocs)
free (internal_relocs);
@@ -4505,12 +4498,10 @@ mn10300_elf_get_relocated_section_contents (bfd *output_bfd,
return data;
error_return:
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && internal_relocs != elf_section_data (input_section)->relocs)
+ if (internal_relocs != elf_section_data (input_section)->relocs)
free (internal_relocs);
return NULL;
}
diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c
index 35b8219..a2f4d51 100644
--- a/bfd/elf-strtab.c
+++ b/bfd/elf-strtab.c
@@ -443,8 +443,7 @@ _bfd_elf_strtab_finalize (struct elf_strtab_hash *tab)
}
alloc_failure:
- if (array)
- free (array);
+ free (array);
/* Assign positions to the strings we want to keep. */
sec_size = 1;
diff --git a/bfd/elf.c b/bfd/elf.c
index 0211970..e335ff7 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -513,17 +513,14 @@ bfd_elf_get_elf_syms (bfd *ibfd,
_bfd_error_handler (_("%pB symbol number %lu references"
" nonexistent SHT_SYMTAB_SHNDX section"),
ibfd, (unsigned long) symoffset);
- if (alloc_intsym != NULL)
- free (alloc_intsym);
+ free (alloc_intsym);
intsym_buf = NULL;
goto out;
}
out:
- if (alloc_ext != NULL)
- free (alloc_ext);
- if (alloc_extshndx != NULL)
- free (alloc_extshndx);
+ free (alloc_ext);
+ free (alloc_extshndx);
return intsym_buf;
}
@@ -1878,8 +1875,7 @@ _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg)
return TRUE;
error_return:
- if (dynbuf != NULL)
- free (dynbuf);
+ free (dynbuf);
return FALSE;
}
@@ -5252,8 +5248,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
return TRUE;
error_return:
- if (sections != NULL)
- free (sections);
+ free (sections);
return FALSE;
}
@@ -9037,8 +9032,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bfd_boolean default_imported_symver)
return TRUE;
error_return:
- if (contents != NULL)
- free (contents);
+ free (contents);
return FALSE;
}
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index df6e3c4..5429a46 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -3128,21 +3128,17 @@ arc_elf_relax_section (bfd *abfd, asection *sec,
elf_section_data (sec)->this_hdr.contents = contents;
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 02d43a8..927a527 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -6617,9 +6617,7 @@ elf32_arm_size_stubs (bfd *output_bfd,
free (internal_relocs);
/* Fall through. */
error_ret_free_local:
- if (local_syms != NULL
- && (symtab_hdr->contents
- != (unsigned char *) local_syms))
+ if (symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms);
return FALSE;
}
@@ -7986,13 +7984,11 @@ bfd_elf32_arm_process_before_allocation (bfd *abfd,
}
}
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
contents = NULL;
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
internal_relocs = NULL;
}
@@ -8000,11 +7996,9 @@ bfd_elf32_arm_process_before_allocation (bfd *abfd,
return TRUE;
error_return:
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
@@ -8607,8 +8601,7 @@ bfd_elf32_arm_vfp11_erratum_scan (bfd *abfd, struct bfd_link_info *link_info)
}
}
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
contents = NULL;
}
@@ -8616,8 +8609,7 @@ bfd_elf32_arm_vfp11_erratum_scan (bfd *abfd, struct bfd_link_info *link_info)
return TRUE;
error_return:
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
return FALSE;
@@ -9044,8 +9036,7 @@ bfd_elf32_arm_stm32l4xx_erratum_scan (bfd *abfd,
}
}
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
contents = NULL;
}
@@ -9053,8 +9044,7 @@ bfd_elf32_arm_stm32l4xx_erratum_scan (bfd *abfd,
return TRUE;
error_return:
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
return FALSE;
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 2a6e743..d4ad18c 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -858,10 +858,8 @@ elf32_avr_link_hash_table_free (bfd *obfd)
= (struct elf32_avr_link_hash_table *) obfd->link.hash;
/* Free the address mapping table. */
- if (htab->amt_stub_offsets != NULL)
- free (htab->amt_stub_offsets);
- if (htab->amt_destination_addr != NULL)
- free (htab->amt_destination_addr);
+ free (htab->amt_stub_offsets);
+ free (htab->amt_destination_addr);
bfd_hash_table_free (&htab->bstab);
_bfd_elf_link_hash_table_free (obfd);
@@ -3166,21 +3164,17 @@ elf32_avr_relax_section (bfd *abfd,
}
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
@@ -3273,10 +3267,8 @@ elf32_avr_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections))
goto error_return;
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
@@ -3285,13 +3277,10 @@ elf32_avr_get_relocated_section_contents (bfd *output_bfd,
return data;
error_return:
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (input_section)->relocs != internal_relocs)
+ if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
return NULL;
}
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index a51a8e8..b06daf5 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -5395,18 +5395,16 @@ bfd_bfin_elf32_create_embedded_relocs (bfd *abfd,
strncpy ((char *) p + 4, targetsec->output_section->name, 8);
}
- if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (datasec)->relocs != internal_relocs)
+ if (elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (datasec)->relocs != internal_relocs)
+ if (elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
}
diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c
index c74cb22..62906c8 100644
--- a/bfd/elf32-cr16.c
+++ b/bfd/elf32-cr16.c
@@ -824,10 +824,9 @@ cr16_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
}
}
- result = TRUE;
- fail:
- if (isymbuf != NULL)
- free (isymbuf);
+ result = TRUE;
+ fail:
+ free (isymbuf);
return result;
}
@@ -1572,10 +1571,8 @@ elf32_cr16_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections))
goto error_return;
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
@@ -1584,13 +1581,10 @@ elf32_cr16_get_relocated_section_contents (bfd *output_bfd,
return data;
error_return:
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (input_section)->relocs != internal_relocs)
+ if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
return NULL;
}
@@ -2174,21 +2168,17 @@ elf32_cr16_relax_section (bfd *abfd, asection *sec,
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
@@ -2847,18 +2837,16 @@ bfd_cr16_elf32_create_embedded_relocs (bfd *abfd,
strncpy ((char *) p + 4, targetsec->output_section->name, 4);
}
- if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (datasec)->relocs != internal_relocs)
+ if (elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (datasec)->relocs != internal_relocs)
+ if (elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
}
diff --git a/bfd/elf32-crx.c b/bfd/elf32-crx.c
index 1c97dd8..82f1a3e 100644
--- a/bfd/elf32-crx.c
+++ b/bfd/elf32-crx.c
@@ -805,10 +805,8 @@ elf32_crx_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections))
goto error_return;
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
@@ -817,13 +815,10 @@ elf32_crx_get_relocated_section_contents (bfd *output_bfd,
return data;
error_return:
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (input_section)->relocs != internal_relocs)
+ if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
return NULL;
}
@@ -1289,21 +1284,17 @@ elf32_crx_relax_section (bfd *abfd, asection *sec,
}
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
diff --git a/bfd/elf32-epiphany.c b/bfd/elf32-epiphany.c
index c0e3ae5..9e61ed5 100644
--- a/bfd/elf32-epiphany.c
+++ b/bfd/elf32-epiphany.c
@@ -341,21 +341,17 @@ epiphany_elf_relax_section (bfd *abfd, asection *sec,
}
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
}
diff --git a/bfd/elf32-ft32.c b/bfd/elf32-ft32.c
index 4a3120b..78457d5 100644
--- a/bfd/elf32-ft32.c
+++ b/bfd/elf32-ft32.c
@@ -1230,15 +1230,13 @@ ft32_elf_relax_section
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (free_relocs != NULL)
- free (free_relocs);
+ free (free_relocs);
return TRUE;
}
diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c
index fdf538d..5488500 100644
--- a/bfd/elf32-h8300.c
+++ b/bfd/elf32-h8300.c
@@ -1465,21 +1465,17 @@ elf32_h8_relax_section (bfd *abfd, asection *sec,
}
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
}
@@ -1682,10 +1678,8 @@ elf32_h8_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections))
goto error_return;
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
@@ -1694,13 +1688,10 @@ elf32_h8_get_relocated_section_contents (bfd *output_bfd,
return data;
error_return:
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (input_section)->relocs != internal_relocs)
+ if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
return NULL;
}
diff --git a/bfd/elf32-ip2k.c b/bfd/elf32-ip2k.c
index ca40335..c0c8b8e 100644
--- a/bfd/elf32-ip2k.c
+++ b/bfd/elf32-ip2k.c
@@ -638,8 +638,7 @@ adjust_all_relocations (bfd *abfd,
{
if (!bfd_malloc_and_get_section (abfd, stab, &stabcontents))
{
- if (stabcontents != NULL)
- free (stabcontents);
+ free (stabcontents);
return;
}
@@ -1210,21 +1209,17 @@ ip2k_elf_relax_section (bfd *abfd,
}
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
}
diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c
index a357f62..7a97d6d 100644
--- a/bfd/elf32-m32c.c
+++ b/bfd/elf32-m32c.c
@@ -1901,11 +1901,8 @@ m32c_elf_relax_section
} /* next relocation */
- if (free_relocs != NULL)
- {
- free (free_relocs);
- free_relocs = NULL;
- }
+ free (free_relocs);
+ free_relocs = NULL;
if (free_contents != NULL)
{
@@ -1931,7 +1928,7 @@ m32c_elf_relax_section
/* Cache the symbols for elf_link_input_bfd. */
else
{
- symtab_hdr->contents = NULL /* (unsigned char *) intsyms*/;
+ symtab_hdr->contents = NULL /* (unsigned char *) intsyms*/;
}
free_intsyms = NULL;
@@ -1940,17 +1937,14 @@ m32c_elf_relax_section
return TRUE;
error_return:
- if (free_relocs != NULL)
- free (free_relocs);
- if (free_contents != NULL)
- free (free_contents);
+ free (free_relocs);
+ free (free_contents);
if (shndx_buf != NULL)
{
shndx_hdr->contents = NULL;
free (shndx_buf);
}
- if (free_intsyms != NULL)
- free (free_intsyms);
+ free (free_intsyms);
return FALSE;
}
diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c
index 46aa438..7bbb489 100644
--- a/bfd/elf32-m68hc11.c
+++ b/bfd/elf32-m68hc11.c
@@ -1082,11 +1082,8 @@ m68hc11_elf_relax_section (bfd *abfd, asection *sec,
prev_insn_group = 0;
}
- if (free_relocs != NULL)
- {
- free (free_relocs);
- free_relocs = NULL;
- }
+ free (free_relocs);
+ free_relocs = NULL;
if (free_contents != NULL)
{
@@ -1115,12 +1112,9 @@ m68hc11_elf_relax_section (bfd *abfd, asection *sec,
return TRUE;
error_return:
- if (free_relocs != NULL)
- free (free_relocs);
- if (free_contents != NULL)
- free (free_contents);
- if (free_extsyms != NULL)
- free (free_extsyms);
+ free (free_relocs);
+ free (free_contents);
+ free (free_extsyms);
return FALSE;
}
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 5b9d420..868435a 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -4448,18 +4448,16 @@ bfd_m68k_elf32_create_embedded_relocs (bfd *abfd, struct bfd_link_info *info,
strncpy ((char *) p + 4, targetsec->output_section->name, 8);
}
- if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (datasec)->relocs != internal_relocs)
+ if (elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (datasec)->relocs != internal_relocs)
+ if (elf_section_data (datasec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
}
diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index bccb0af..f88da8f 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -2234,11 +2234,8 @@ microblaze_elf_relax_section (bfd *abfd,
symtab_hdr->contents = (bfd_byte *) isymbuf;
}
- if (free_relocs != NULL)
- {
- free (free_relocs);
- free_relocs = NULL;
- }
+ free (free_relocs);
+ free_relocs = NULL;
if (free_contents != NULL)
{
@@ -2261,16 +2258,11 @@ microblaze_elf_relax_section (bfd *abfd,
return TRUE;
error_return:
- if (free_relocs != NULL)
- free (free_relocs);
- if (free_contents != NULL)
- free (free_contents);
- if (sec->relax != NULL)
- {
- free (sec->relax);
- sec->relax = NULL;
- sec->relax_count = 0;
- }
+ free (free_relocs);
+ free (free_contents);
+ free (sec->relax);
+ sec->relax = NULL;
+ sec->relax_count = 0;
return FALSE;
}
diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c
index 9670213..59e54ec 100644
--- a/bfd/elf32-msp430.c
+++ b/bfd/elf32-msp430.c
@@ -2487,20 +2487,17 @@ msp430_elf_relax_section (bfd * abfd, asection * sec,
}
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c
index a5a681a..2d26e2a 100644
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -12572,15 +12572,13 @@ nds32_elf_relax_section (bfd *abfd, asection *sec,
}
finish:
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (isymbuf != NULL && symtab_hdr->contents != (bfd_byte *) isymbuf)
+ if (symtab_hdr->contents != (bfd_byte *) isymbuf)
free (isymbuf);
return result;
@@ -13473,7 +13471,7 @@ elf32_nds32_check_relax_group (bfd *abfd, asection *asec)
}
while (FALSE);
- if ((relocs != NULL) && (elf_section_data (asec)->relocs != relocs))
+ if (elf_section_data (asec)->relocs != relocs)
free (relocs);
if ((min_id != relax_group_ptr->min_id)
@@ -13612,7 +13610,7 @@ elf32_nds32_unify_relax_group (bfd *abfd, asection *asec)
}
while (FALSE);
- if (relocs != NULL && elf_section_data (asec)->relocs != relocs)
+ if (elf_section_data (asec)->relocs != relocs)
free (relocs);
return result;
@@ -14038,15 +14036,13 @@ nds32_elf_unify_tls_model (bfd *inbfd, asection *insec, bfd_byte *incontents,
if (incontents)
contents = NULL;
- if (internal_relocs != NULL
- && elf_section_data (insec)->relocs != internal_relocs)
+ if (elf_section_data (insec)->relocs != internal_relocs)
free (internal_relocs);
- if (contents != NULL
- && elf_section_data (insec)->this_hdr.contents != contents)
+ if (elf_section_data (insec)->this_hdr.contents != contents)
free (contents);
- if (local_syms != NULL && symtab_hdr->contents != (bfd_byte *) local_syms)
+ if (symtab_hdr->contents != (bfd_byte *) local_syms)
free (local_syms);
if (chain.next)
diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
index bfb6fd1..0b2e68e 100644
--- a/bfd/elf32-nios2.c
+++ b/bfd/elf32-nios2.c
@@ -4538,8 +4538,7 @@ nios2_elf32_relocate_section (bfd *output_bfd,
{
(*info->callbacks->warning) (info, msg, name, input_bfd,
input_section, rel->r_offset);
- if (msgbuf)
- free (msgbuf);
+ free (msgbuf);
return FALSE;
}
}
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 053687c..a900abe 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -1633,8 +1633,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info)
apuinfo_set = TRUE;
if (largest_input_size < asec->size)
{
- if (buffer)
- free (buffer);
+ free (buffer);
largest_input_size = asec->size;
buffer = bfd_malloc (largest_input_size);
if (!buffer)
@@ -1692,8 +1691,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info)
}
fail:
- if (buffer)
- free (buffer);
+ free (buffer);
if (error_message)
_bfd_error_handler (error_message, APUINFO_SECTION_NAME, ibfd);
@@ -4263,8 +4261,7 @@ ppc_elf_inline_plt (struct bfd_link_info *info)
{
if (elf_section_data (sec)->relocs != relstart)
free (relstart);
- if (local_syms != NULL
- && symtab_hdr->contents != (unsigned char *) local_syms)
+ if (symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms);
return FALSE;
}
@@ -6651,8 +6648,7 @@ ppc_elf_relax_section (bfd *abfd,
rel_hdr = _bfd_elf_single_rel_hdr (isec);
rel_hdr->sh_size += changes * rel_hdr->sh_entsize;
}
- else if (internal_relocs != NULL
- && elf_section_data (isec)->relocs != internal_relocs)
+ else if (elf_section_data (isec)->relocs != internal_relocs)
free (internal_relocs);
*again = changes != 0 || workaround_change;
@@ -6665,13 +6661,11 @@ ppc_elf_relax_section (bfd *abfd,
branch_fixups = branch_fixups->next;
free (f);
}
- if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
+ if ((unsigned char *) isymbuf != symtab_hdr->contents)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (isec)->this_hdr.contents != contents)
+ if (elf_section_data (isec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (isec)->relocs != internal_relocs)
+ if (elf_section_data (isec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
}
@@ -9710,8 +9704,7 @@ ppc_finish_symbols (struct bfd_link_info *info)
if (!get_sym_h (NULL, &sym, &sym_sec, NULL, &local_syms,
lplt - local_plt, ibfd))
{
- if (local_syms != NULL
- && symtab_hdr->contents != (unsigned char *) local_syms)
+ if (symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms);
return FALSE;
}
diff --git a/bfd/elf32-pru.c b/bfd/elf32-pru.c
index e9063f6..bc44a1b 100644
--- a/bfd/elf32-pru.c
+++ b/bfd/elf32-pru.c
@@ -1523,20 +1523,17 @@ pru_elf32_relax_section (bfd * abfd, asection * sec,
}
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c
index 633350f..3929776 100644
--- a/bfd/elf32-rl78.c
+++ b/bfd/elf32-rl78.c
@@ -2552,11 +2552,8 @@ rl78_elf_relax_section
return TRUE;
error_return:
- if (free_relocs != NULL)
- free (free_relocs);
-
- if (free_contents != NULL)
- free (free_contents);
+ free (free_relocs);
+ free (free_contents);
if (shndx_buf != NULL)
{
@@ -2564,8 +2561,7 @@ rl78_elf_relax_section
free (shndx_buf);
}
- if (free_intsyms != NULL)
- free (free_intsyms);
+ free (free_intsyms);
return TRUE;
}
diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c
index 89b7ed5..3f03ab2 100644
--- a/bfd/elf32-rx.c
+++ b/bfd/elf32-rx.c
@@ -3037,8 +3037,7 @@ elf32_rx_relax_section (bfd * abfd,
return TRUE;
error_return:
- if (free_contents != NULL)
- free (free_contents);
+ free (free_contents);
if (shndx_buf != NULL)
{
@@ -3046,8 +3045,7 @@ elf32_rx_relax_section (bfd * abfd,
free (shndx_buf);
}
- if (free_intsyms != NULL)
- free (free_intsyms);
+ free (free_intsyms);
return FALSE;
}
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 24203e0..7daf851 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -167,8 +167,7 @@ sh_elf_reloc_loop (int r_type ATTRIBUTE_UNUSED, bfd *input_bfd,
if (!bfd_malloc_and_get_section (input_bfd, symbol_section,
&contents))
{
- if (contents != NULL)
- free (contents);
+ free (contents);
return bfd_reloc_outofrange;
}
}
@@ -203,8 +202,7 @@ sh_elf_reloc_loop (int r_type ATTRIBUTE_UNUSED, bfd *input_bfd,
end = start0;
}
- if (contents != NULL
- && elf_section_data (symbol_section)->this_hdr.contents != contents)
+ if (elf_section_data (symbol_section)->this_hdr.contents != contents)
free (contents);
insn = bfd_get_16 (input_bfd, contents + addr);
@@ -811,21 +809,17 @@ sh_elf_relax_section (bfd *abfd, asection *sec,
}
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
@@ -1195,8 +1189,7 @@ sh_elf_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr,
when we leave sh_coff_relax_section. */
if (!bfd_malloc_and_get_section (abfd, o, &ocontents))
{
- if (ocontents != NULL)
- free (ocontents);
+ free (ocontents);
return FALSE;
}
@@ -1253,8 +1246,7 @@ sh_elf_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr,
when we leave sh_coff_relax_section. */
if (!bfd_malloc_and_get_section (abfd, o, &ocontents))
{
- if (ocontents != NULL)
- free (ocontents);
+ free (ocontents);
return FALSE;
}
@@ -1387,8 +1379,7 @@ sh_elf_align_loads (bfd *abfd ATTRIBUTE_UNUSED, asection *sec,
return TRUE;
error_return:
- if (labels != NULL)
- free (labels);
+ free (labels);
return FALSE;
}
@@ -5257,10 +5248,8 @@ sh_elf_get_relocated_section_contents (bfd *output_bfd,
isymbuf, sections))
goto error_return;
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
@@ -5269,13 +5258,10 @@ sh_elf_get_relocated_section_contents (bfd *output_bfd,
return data;
error_return:
- if (sections != NULL)
- free (sections);
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ free (sections);
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (input_section)->relocs != internal_relocs)
+ if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
return NULL;
}
diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c
index 193438c..dcdee26 100644
--- a/bfd/elf32-spu.c
+++ b/bfd/elf32-spu.c
@@ -1598,9 +1598,7 @@ process_stubs (struct bfd_link_info *info, bfd_boolean build)
if (elf_section_data (isec)->relocs != internal_relocs)
free (internal_relocs);
error_ret_free_local:
- if (local_syms != NULL
- && (symtab_hdr->contents
- != (unsigned char *) local_syms))
+ if (symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms);
return FALSE;
}
@@ -3013,13 +3011,10 @@ discover_functions (struct bfd_link_info *info)
continue;
}
- if (symtab_hdr->contents != NULL)
- {
- /* Don't use cached symbols since the generic ELF linker
- code only reads local symbols, and we need globals too. */
- free (symtab_hdr->contents);
- symtab_hdr->contents = NULL;
- }
+ /* Don't use cached symbols since the generic ELF linker
+ code only reads local symbols, and we need globals too. */
+ free (symtab_hdr->contents);
+ symtab_hdr->contents = NULL;
syms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, symcount, 0,
NULL, NULL, NULL);
symtab_hdr->contents = (void *) syms;
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index bf37a93..0235044 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -4093,16 +4093,13 @@ v850_elf_relax_section (bfd *abfd,
}
finish:
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != (unsigned char *) contents)
+ if (elf_section_data (sec)->this_hdr.contents != (unsigned char *) contents)
free (contents);
- if (isymbuf != NULL
- && symtab_hdr->contents != (bfd_byte *) isymbuf)
+ if (symtab_hdr->contents != (bfd_byte *) isymbuf)
free (isymbuf);
return result;
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 4327b02..05c4f84 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -3048,9 +3048,7 @@ elf_xtensa_relocate_section (bfd *output_bfd,
}
}
- if (lit_table)
- free (lit_table);
-
+ free (lit_table);
input_section->reloc_done = TRUE;
return TRUE;
@@ -3130,8 +3128,7 @@ elf_xtensa_combine_prop_entries (bfd *output_bfd,
if (!bfd_malloc_and_get_section (output_bfd, sxtlit, &contents))
{
- if (contents != 0)
- free (contents);
+ free (contents);
free (table);
return -1;
}
@@ -6295,8 +6292,7 @@ free_section_cache (section_cache_t *sec_cache)
{
release_contents (sec_cache->sec, sec_cache->contents);
release_internal_relocs (sec_cache->sec, sec_cache->relocs);
- if (sec_cache->ptbl)
- free (sec_cache->ptbl);
+ free (sec_cache->ptbl);
}
}
@@ -6353,8 +6349,7 @@ section_cache_section (section_cache_t *sec_cache,
err:
release_contents (sec, contents);
release_internal_relocs (sec, internal_relocs);
- if (prop_table)
- free (prop_table);
+ free (prop_table);
return FALSE;
}
@@ -6473,8 +6468,7 @@ init_ebb_constraint (ebb_constraint *c)
static void
free_ebb_constraint (ebb_constraint *c)
{
- if (c->actions)
- free (c->actions);
+ free (c->actions);
}
@@ -6708,8 +6702,7 @@ ebb_propose_action (ebb_constraint *c,
for (i = 0; i < c->action_count; i++)
new_actions[i] = c->actions[i];
- if (c->actions)
- free (c->actions);
+ free (c->actions);
c->actions = new_actions;
c->action_allocated = new_allocated;
}
@@ -6761,8 +6754,7 @@ pin_internal_relocs (asection *sec, Elf_Internal_Rela *internal_relocs)
static void
release_internal_relocs (asection *sec, Elf_Internal_Rela *internal_relocs)
{
- if (internal_relocs
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
}
@@ -6780,8 +6772,7 @@ retrieve_contents (bfd *abfd, asection *sec, bfd_boolean keep_memory)
{
if (!bfd_malloc_and_get_section (abfd, sec, &contents))
{
- if (contents)
- free (contents);
+ free (contents);
return NULL;
}
if (keep_memory)
@@ -6801,7 +6792,7 @@ pin_contents (asection *sec, bfd_byte *contents)
static void
release_contents (asection *sec, bfd_byte *contents)
{
- if (contents && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
}
@@ -7886,10 +7877,8 @@ compute_text_actions (bfd *abfd,
error_return:
release_contents (sec, contents);
release_internal_relocs (sec, internal_relocs);
- if (prop_table)
- free (prop_table);
- if (reloc_opcodes)
- free (reloc_opcodes);
+ free (prop_table);
+ free (reloc_opcodes);
return ok;
}
@@ -8489,10 +8478,11 @@ build_xlate_map (asection *sec, xtensa_relax_info *relax_info)
static void
free_xlate_map (xlate_map_t *map)
{
- if (map && map->entry)
- free (map->entry);
if (map)
- free (map);
+ {
+ free (map->entry);
+ free (map);
+ }
}
@@ -8676,8 +8666,7 @@ check_section_ebb_pcrels_fit (bfd *abfd,
}
}
- if (xmap)
- free_xlate_map (xmap);
+ free_xlate_map (xmap);
return ok;
}
@@ -8889,8 +8878,7 @@ compute_removed_literals (bfd *abfd,
#endif /* DEBUG */
error_return:
- if (prop_table)
- free (prop_table);
+ free (prop_table);
free_section_cache (&target_sec_cache);
release_contents (sec, contents);
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 8f73212..4e4efae 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -1422,30 +1422,18 @@ elf64_alpha_read_ecoff_info (bfd *abfd, asection *section,
return TRUE;
error_return:
- if (ext_hdr != NULL)
- free (ext_hdr);
- if (debug->line != NULL)
- free (debug->line);
- if (debug->external_dnr != NULL)
- free (debug->external_dnr);
- if (debug->external_pdr != NULL)
- free (debug->external_pdr);
- if (debug->external_sym != NULL)
- free (debug->external_sym);
- if (debug->external_opt != NULL)
- free (debug->external_opt);
- if (debug->external_aux != NULL)
- free (debug->external_aux);
- if (debug->ss != NULL)
- free (debug->ss);
- if (debug->ssext != NULL)
- free (debug->ssext);
- if (debug->external_fdr != NULL)
- free (debug->external_fdr);
- if (debug->external_rfd != NULL)
- free (debug->external_rfd);
- if (debug->external_ext != NULL)
- free (debug->external_ext);
+ free (ext_hdr);
+ free (debug->line);
+ free (debug->external_dnr);
+ free (debug->external_pdr);
+ free (debug->external_sym);
+ free (debug->external_opt);
+ free (debug->external_aux);
+ free (debug->ss);
+ free (debug->ssext);
+ free (debug->external_fdr);
+ free (debug->external_rfd);
+ free (debug->external_ext);
return FALSE;
}
@@ -3186,12 +3174,10 @@ elf64_alpha_relax_opt_call (struct alpha_relax_info *info, bfd_vma symval)
if (!gpdisp || gpdisp->r_addend != 4)
{
- if (tsec_free)
- free (tsec_free);
+ free (tsec_free);
return 0;
}
- if (tsec_free)
- free (tsec_free);
+ free (tsec_free);
}
/* We've now determined that we can skip an initial gp load. Verify
@@ -4037,14 +4023,11 @@ elf64_alpha_relax_section (bfd *abfd, asection *sec,
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (info.contents != NULL
- && elf_section_data (sec)->this_hdr.contents != info.contents)
+ if (elf_section_data (sec)->this_hdr.contents != info.contents)
free (info.contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
}
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 0fdbea4..7fc2dc0 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -534,8 +534,7 @@ elf64_hppa_check_relocs (bfd *abfd,
?!? Note we leak the last section_syms array. Presumably we
could free it in one of the later routines in this file. */
- if (hppa_info->section_syms)
- free (hppa_info->section_syms);
+ free (hppa_info->section_syms);
/* Read this BFD's local symbols. */
if (symtab_hdr->sh_info != 0)
diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c
index 6fa116f..a97858e 100644
--- a/bfd/elf64-ia64-vms.c
+++ b/bfd/elf64-ia64-vms.c
@@ -792,13 +792,11 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
return TRUE;
error_return:
- if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
+ if ((unsigned char *) isymbuf != symtab_hdr->contents)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
}
@@ -999,14 +997,11 @@ elf64_ia64_global_dyn_info_free (void **xentry,
if (entry->root.root.type == bfd_link_hash_warning)
entry = (struct elf64_ia64_link_hash_entry *) entry->root.root.u.i.link;
- if (entry->info)
- {
- free (entry->info);
- entry->info = NULL;
- entry->count = 0;
- entry->sorted_count = 0;
- entry->size = 0;
- }
+ free (entry->info);
+ entry->info = NULL;
+ entry->count = 0;
+ entry->sorted_count = 0;
+ entry->size = 0;
return TRUE;
}
@@ -1020,14 +1015,11 @@ elf64_ia64_local_dyn_info_free (void **slot,
struct elf64_ia64_local_hash_entry *entry
= (struct elf64_ia64_local_hash_entry *) *slot;
- if (entry->info)
- {
- free (entry->info);
- entry->info = NULL;
- entry->count = 0;
- entry->sorted_count = 0;
- entry->size = 0;
- }
+ free (entry->info);
+ entry->info = NULL;
+ entry->count = 0;
+ entry->sorted_count = 0;
+ entry->size = 0;
return TRUE;
}
@@ -5242,11 +5234,8 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
}
}
- if (isymbuf != NULL)
- {
- free (isymbuf);
- isymbuf = NULL;
- }
+ free (isymbuf);
+ isymbuf = NULL;
/* If this object is the same format as the output object, and it is
not a shared library, then let the backend look through the
@@ -5303,8 +5292,7 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
error_free_vers:
error_free_sym:
- if (isymbuf != NULL)
- free (isymbuf);
+ free (isymbuf);
error_return:
return FALSE;
}
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index 413018f..a07c39f 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -4162,14 +4162,11 @@ mips_elf64_slurp_one_reloc_table (bfd *abfd, asection *asect,
}
}
- if (allocated != NULL)
- free (allocated);
-
+ free (allocated);
return TRUE;
error_return:
- if (allocated != NULL)
- free (allocated);
+ free (allocated);
return FALSE;
}
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index 2c936ba..fee4a0f 100644
--- a/bfd/elf64-mmix.c
+++ b/bfd/elf64-mmix.c
@@ -2844,8 +2844,7 @@ mmix_elf_relax_section (bfd *abfd,
BFD_ASSERT(pjsno == mmix_elf_section_data (sec)->pjs.n_pushj_relocs);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
if (sec->size < size + mmix_elf_section_data (sec)->pjs.stubs_size_sum)
@@ -2860,10 +2859,9 @@ mmix_elf_relax_section (bfd *abfd,
return TRUE;
error_return:
- if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
+ if ((unsigned char *) isymbuf != symtab_hdr->contents)
free (isymbuf);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
}
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index da4a8c7..bbd8aee 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -2422,8 +2422,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
free_contents_and_exit_err:
count = -1;
free_contents_and_exit:
- if (contents)
- free (contents);
+ free (contents);
goto done;
}
@@ -7303,11 +7302,9 @@ ppc64_elf_edit_opd (struct bfd_link_info *info)
bfd_byte *loc;
if (!bfd_malloc_and_get_section (ibfd, sec, &loc))
{
- if (loc != NULL)
- free (loc);
+ free (loc);
error_ret:
- if (local_syms != NULL
- && symtab_hdr->contents != (unsigned char *) local_syms)
+ if (symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms);
if (elf_section_data (sec)->relocs != relstart)
free (relstart);
@@ -7633,8 +7630,7 @@ ppc64_elf_inline_plt (struct bfd_link_info *info)
{
if (elf_section_data (sec)->relocs != relstart)
free (relstart);
- if (local_syms != NULL
- && symtab_hdr->contents != (bfd_byte *) local_syms)
+ if (symtab_hdr->contents != (bfd_byte *) local_syms)
free (local_syms);
return FALSE;
}
@@ -7975,11 +7971,9 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
err_free_rel:
if (elf_section_data (sec)->relocs != relstart)
free (relstart);
- if (toc_ref != NULL)
- free (toc_ref);
- if (locsyms != NULL
- && (elf_symtab_hdr (ibfd).contents
- != (unsigned char *) locsyms))
+ free (toc_ref);
+ if (elf_symtab_hdr (ibfd).contents
+ != (unsigned char *) locsyms)
free (locsyms);
return ret;
}
@@ -8394,8 +8388,7 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
}
}
- if (toc_ref != NULL)
- free (toc_ref);
+ free (toc_ref);
htab->do_tls_opt = 1;
return TRUE;
}
@@ -8835,18 +8828,14 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
if (used == NULL)
{
error_ret:
- if (local_syms != NULL
- && symtab_hdr->contents != (unsigned char *) local_syms)
+ if (symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms);
if (sec != NULL
- && relstart != NULL
&& elf_section_data (sec)->relocs != relstart)
free (relstart);
- if (toc_relocs != NULL
- && elf_section_data (toc)->relocs != toc_relocs)
+ if (elf_section_data (toc)->relocs != toc_relocs)
free (toc_relocs);
- if (skip != NULL)
- free (skip);
+ free (skip);
return FALSE;
}
@@ -9213,8 +9202,7 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
rel_hdr->sh_size = toc->reloc_count * sz;
}
}
- else if (toc_relocs != NULL
- && elf_section_data (toc)->relocs != toc_relocs)
+ else if (elf_section_data (toc)->relocs != toc_relocs)
free (toc_relocs);
if (local_syms != NULL
@@ -9265,11 +9253,9 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
if (relstart == NULL)
{
got_error_ret:
- if (local_syms != NULL
- && symtab_hdr->contents != (unsigned char *) local_syms)
+ if (symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms);
if (sec != NULL
- && relstart != NULL
&& elf_section_data (sec)->relocs != relstart)
free (relstart);
return FALSE;
@@ -12792,9 +12778,8 @@ toc_adjusting_stub_needed (struct bfd_link_info *info, asection *isec)
}
}
- if (local_syms != NULL
- && (elf_symtab_hdr (isec->owner).contents
- != (unsigned char *) local_syms))
+ if (elf_symtab_hdr (isec->owner).contents
+ != (unsigned char *) local_syms)
free (local_syms);
if (elf_section_data (isec)->relocs != relstart)
free (relstart);
@@ -13547,9 +13532,8 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
if (elf_section_data (section)->relocs == NULL)
free (internal_relocs);
error_ret_free_local:
- if (local_syms != NULL
- && (symtab_hdr->contents
- != (unsigned char *) local_syms))
+ if (symtab_hdr->contents
+ != (unsigned char *) local_syms)
free (local_syms);
return FALSE;
}
@@ -14120,8 +14104,7 @@ write_plt_relocs_for_local_syms (struct bfd_link_info *info)
if (!get_sym_h (NULL, &sym, &sym_sec, NULL, &local_syms,
lplt - local_plt, ibfd))
{
- if (local_syms != NULL
- && symtab_hdr->contents != (unsigned char *) local_syms)
+ if (symtab_hdr->contents != (unsigned char *) local_syms)
free (local_syms);
return FALSE;
}
@@ -17199,8 +17182,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
reloc_name, sym_name, (int) r);
ret = FALSE;
}
- if (more_info != NULL)
- free (more_info);
+ free (more_info);
}
copy_reloc:
if (wrel != rel)
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index f07c062..8d35225 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -161,14 +161,11 @@ elf64_sparc_slurp_one_reloc_table (bfd *abfd, asection *asect,
canon_reloc_count (asect) += relent - relents;
- if (allocated != NULL)
- free (allocated);
-
+ free (allocated);
return TRUE;
error_return:
- if (allocated != NULL)
- free (allocated);
+ free (allocated);
return FALSE;
}
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 5e6b2a4..2e2c534 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -1144,8 +1144,7 @@ elf_checksum_contents (bfd *abfd,
if (contents != NULL)
{
(*process) (contents, i_shdr.sh_size, arg);
- if (free_contents != NULL)
- free (free_contents);
+ free (free_contents);
}
}
@@ -1402,16 +1401,14 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
*symptrs = 0; /* Final null pointer */
}
- if (xverbuf != NULL)
- free (xverbuf);
- if (isymbuf != NULL && hdr->contents != (unsigned char *) isymbuf)
+ free (xverbuf);
+ if (hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
return symcount;
error_return:
- if (xverbuf != NULL)
- free (xverbuf);
- if (isymbuf != NULL && hdr->contents != (unsigned char *) isymbuf)
+ free (xverbuf);
+ if (hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
return -1;
}
@@ -1509,13 +1506,11 @@ elf_slurp_reloc_table_from_section (bfd *abfd,
goto error_return;
}
- if (allocated != NULL)
- free (allocated);
+ free (allocated);
return TRUE;
error_return:
- if (allocated != NULL)
- free (allocated);
+ free (allocated);
return FALSE;
}
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 90ada7a..c157aea 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -2643,8 +2643,7 @@ _bfd_elf_link_read_relocs (bfd *abfd,
if (keep_memory)
esdo->relocs = internal_relocs;
- if (alloc1 != NULL)
- free (alloc1);
+ free (alloc1);
/* Don't free alloc2, since if it was allocated we are passing it
back (under the name of internal_relocs). */
@@ -2652,8 +2651,7 @@ _bfd_elf_link_read_relocs (bfd *abfd,
return internal_relocs;
error_return:
- if (alloc1 != NULL)
- free (alloc1);
+ free (alloc1);
if (alloc2 != NULL)
{
if (keep_memory)
@@ -5299,17 +5297,10 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
}
}
- if (extversym != NULL)
- {
- free (extversym);
- extversym = NULL;
- }
-
- if (isymbuf != NULL)
- {
- free (isymbuf);
- isymbuf = NULL;
- }
+ free (extversym);
+ extversym = NULL;
+ free (isymbuf);
+ isymbuf = NULL;
if ((elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0)
{
@@ -5389,8 +5380,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
free (old_tab);
objalloc_free_block ((struct objalloc *) htab->root.table.memory,
alloc_mark);
- if (nondeflt_vers != NULL)
- free (nondeflt_vers);
+ free (nondeflt_vers);
return TRUE;
}
@@ -5673,17 +5663,12 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
return TRUE;
error_free_vers:
- if (old_tab != NULL)
- free (old_tab);
- if (old_strtab != NULL)
- free (old_strtab);
- if (nondeflt_vers != NULL)
- free (nondeflt_vers);
- if (extversym != NULL)
- free (extversym);
+ free (old_tab);
+ free (old_strtab);
+ free (nondeflt_vers);
+ free (extversym);
error_free_sym:
- if (isymbuf != NULL)
- free (isymbuf);
+ free (isymbuf);
error_return:
return FALSE;
}
@@ -5891,12 +5876,10 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
while (loop);
free (included);
-
return TRUE;
error_return:
- if (included != NULL)
- free (included);
+ free (included);
return FALSE;
}
@@ -5967,9 +5950,7 @@ elf_collect_hash_codes (struct elf_link_hash_entry *h, void *data)
later. */
h->u.elf_hash_value = ha;
- if (alc != NULL)
- free (alc);
-
+ free (alc);
return TRUE;
}
@@ -6043,9 +6024,7 @@ elf_collect_gnu_hash_codes (struct elf_link_hash_entry *h, void *data)
if (s->min_dynindx < 0 || s->min_dynindx > h->dynindx)
s->min_dynindx = h->dynindx;
- if (alc != NULL)
- free (alc);
-
+ free (alc);
return TRUE;
}
@@ -7973,8 +7952,7 @@ bfd_elf_get_bfd_needed_list (bfd *abfd,
return TRUE;
error_return:
- if (dynbuf != NULL)
- free (dynbuf);
+ free (dynbuf);
return FALSE;
}
@@ -8313,14 +8291,10 @@ bfd_elf_match_symbols_in_sections (asection *sec1, asection *sec2,
result = TRUE;
done:
- if (symtable1)
- free (symtable1);
- if (symtable2)
- free (symtable2);
- if (isymbuf1)
- free (isymbuf1);
- if (isymbuf2)
- free (isymbuf2);
+ free (symtable1);
+ free (symtable2);
+ free (isymbuf1);
+ free (isymbuf2);
return result;
}
@@ -11875,32 +11849,21 @@ elf_final_link_free (bfd *obfd, struct elf_final_link_info *flinfo)
if (flinfo->symstrtab != NULL)
_bfd_elf_strtab_free (flinfo->symstrtab);
- if (flinfo->contents != NULL)
- free (flinfo->contents);
- if (flinfo->external_relocs != NULL)
- free (flinfo->external_relocs);
- if (flinfo->internal_relocs != NULL)
- free (flinfo->internal_relocs);
- if (flinfo->external_syms != NULL)
- free (flinfo->external_syms);
- if (flinfo->locsym_shndx != NULL)
- free (flinfo->locsym_shndx);
- if (flinfo->internal_syms != NULL)
- free (flinfo->internal_syms);
- if (flinfo->indices != NULL)
- free (flinfo->indices);
- if (flinfo->sections != NULL)
- free (flinfo->sections);
- if (flinfo->symshndxbuf != NULL
- && flinfo->symshndxbuf != (Elf_External_Sym_Shndx *) -1)
+ free (flinfo->contents);
+ free (flinfo->external_relocs);
+ free (flinfo->internal_relocs);
+ free (flinfo->external_syms);
+ free (flinfo->locsym_shndx);
+ free (flinfo->internal_syms);
+ free (flinfo->indices);
+ free (flinfo->sections);
+ if (flinfo->symshndxbuf != (Elf_External_Sym_Shndx *) -1)
free (flinfo->symshndxbuf);
for (o = obfd->sections; o != NULL; o = o->next)
{
struct bfd_elf_section_data *esdo = elf_section_data (o);
- if ((o->flags & SEC_RELOC) != 0 && esdo->rel.hashes != NULL)
- free (esdo->rel.hashes);
- if ((o->flags & SEC_RELOC) != 0 && esdo->rela.hashes != NULL)
- free (esdo->rela.hashes);
+ free (esdo->rel.hashes);
+ free (esdo->rela.hashes);
}
}
@@ -12488,8 +12451,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
if (!info->reduce_memory_overheads)
{
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
- if (bfd_get_flavour (sub) == bfd_target_elf_flavour
- && elf_tdata (sub)->symbuf)
+ if (bfd_get_flavour (sub) == bfd_target_elf_flavour)
{
free (elf_tdata (sub)->symbuf);
elf_tdata (sub)->symbuf = NULL;
@@ -13097,8 +13059,7 @@ fini_reloc_cookie (struct elf_reloc_cookie *cookie, bfd *abfd)
Elf_Internal_Shdr *symtab_hdr;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- if (cookie->locsyms != NULL
- && symtab_hdr->contents != (unsigned char *) cookie->locsyms)
+ if (symtab_hdr->contents != (unsigned char *) cookie->locsyms)
free (cookie->locsyms);
}
@@ -13135,7 +13096,7 @@ static void
fini_reloc_cookie_rels (struct elf_reloc_cookie *cookie,
asection *sec)
{
- if (cookie->rels && elf_section_data (sec)->relocs != cookie->rels)
+ if (elf_section_data (sec)->relocs != cookie->rels)
free (cookie->rels);
}
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index 0cdd6b5..d179bc4 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -873,13 +873,11 @@ elfNN_ia64_relax_section (bfd *abfd, asection *sec,
return TRUE;
error_return:
- if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
+ if ((unsigned char *) isymbuf != symtab_hdr->contents)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
}
@@ -1310,8 +1308,7 @@ elfNN_ia64_hash_copy_indirect (struct bfd_link_info *info,
struct elfNN_ia64_dyn_sym_info *dyn_i;
unsigned int count;
- if (dir->info)
- free (dir->info);
+ free (dir->info);
dir->info = ind->info;
dir->count = ind->count;
@@ -1399,14 +1396,11 @@ elfNN_ia64_global_dyn_info_free (void **xentry,
struct elfNN_ia64_link_hash_entry *entry
= (struct elfNN_ia64_link_hash_entry *) xentry;
- if (entry->info)
- {
- free (entry->info);
- entry->info = NULL;
- entry->count = 0;
- entry->sorted_count = 0;
- entry->size = 0;
- }
+ free (entry->info);
+ entry->info = NULL;
+ entry->count = 0;
+ entry->sorted_count = 0;
+ entry->size = 0;
return TRUE;
}
@@ -1420,14 +1414,11 @@ elfNN_ia64_local_dyn_info_free (void **slot,
struct elfNN_ia64_local_hash_entry *entry
= (struct elfNN_ia64_local_hash_entry *) *slot;
- if (entry->info)
- {
- free (entry->info);
- entry->info = NULL;
- entry->count = 0;
- entry->sorted_count = 0;
- entry->size = 0;
- }
+ free (entry->info);
+ entry->info = NULL;
+ entry->count = 0;
+ entry->sorted_count = 0;
+ entry->size = 0;
return TRUE;
}
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index e8e377e..5fa6e35 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -2393,9 +2393,8 @@ riscv_elf_relocate_section (bfd *output_bfd,
if (msg && r != bfd_reloc_dangerous)
info->callbacks->einfo (msg);
- /* Free the unused `msg_buf` if needed. */
- if (msg_buf)
- free (msg_buf);
+ /* Free the unused `msg_buf`. */
+ free (msg_buf);
/* We already reported the error via a callback, so don't try to report
it again by returning false. That leads to spurious errors. */
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 9ce205e..e563d56 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -1450,30 +1450,18 @@ _bfd_mips_elf_read_ecoff_info (bfd *abfd, asection *section,
return TRUE;
error_return:
- if (ext_hdr != NULL)
- free (ext_hdr);
- if (debug->line != NULL)
- free (debug->line);
- if (debug->external_dnr != NULL)
- free (debug->external_dnr);
- if (debug->external_pdr != NULL)
- free (debug->external_pdr);
- if (debug->external_sym != NULL)
- free (debug->external_sym);
- if (debug->external_opt != NULL)
- free (debug->external_opt);
- if (debug->external_aux != NULL)
- free (debug->external_aux);
- if (debug->ss != NULL)
- free (debug->ss);
- if (debug->ssext != NULL)
- free (debug->ssext);
- if (debug->external_fdr != NULL)
- free (debug->external_fdr);
- if (debug->external_rfd != NULL)
- free (debug->external_rfd);
- if (debug->external_ext != NULL)
- free (debug->external_ext);
+ free (ext_hdr);
+ free (debug->line);
+ free (debug->external_dnr);
+ free (debug->external_pdr);
+ free (debug->external_sym);
+ free (debug->external_opt);
+ free (debug->external_aux);
+ free (debug->ss);
+ free (debug->ssext);
+ free (debug->external_fdr);
+ free (debug->external_rfd);
+ free (debug->external_ext);
return FALSE;
}
@@ -1618,30 +1606,19 @@ mips_elf_create_procedure_table (void *handle, bfd *abfd,
matters, but someday it might). */
s->map_head.link_order = NULL;
- if (epdr != NULL)
- free (epdr);
- if (rpdr != NULL)
- free (rpdr);
- if (esym != NULL)
- free (esym);
- if (ss != NULL)
- free (ss);
- if (sv != NULL)
- free (sv);
-
+ free (epdr);
+ free (rpdr);
+ free (esym);
+ free (ss);
+ free (sv);
return TRUE;
error_return:
- if (epdr != NULL)
- free (epdr);
- if (rpdr != NULL)
- free (rpdr);
- if (esym != NULL)
- free (esym);
- if (ss != NULL)
- free (ss);
- if (sv != NULL)
- free (sv);
+ free (epdr);
+ free (rpdr);
+ free (esym);
+ free (ss);
+ free (sv);
return FALSE;
}
@@ -13391,13 +13368,11 @@ _bfd_elf_mips_get_relocated_section_contents
}
}
}
- if (reloc_vector != NULL)
- free (reloc_vector);
+ free (reloc_vector);
return data;
error_return:
- if (reloc_vector != NULL)
- free (reloc_vector);
+ free (reloc_vector);
return NULL;
}
@@ -14274,21 +14249,17 @@ _bfd_mips_elf_relax_section (bfd *abfd, asection *sec,
}
}
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return TRUE;
error_return:
- if (isymbuf != NULL
- && symtab_hdr->contents != (unsigned char *) isymbuf)
+ if (symtab_hdr->contents != (unsigned char *) isymbuf)
free (isymbuf);
- if (contents != NULL
- && elf_section_data (sec)->this_hdr.contents != contents)
+ if (elf_section_data (sec)->this_hdr.contents != contents)
free (contents);
- if (internal_relocs != NULL
- && elf_section_data (sec)->relocs != internal_relocs)
+ if (elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);
return FALSE;
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 0fc75fb..9679dca 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -2451,8 +2451,7 @@ _bfd_x86_elf_get_synthetic_symtab (bfd *abfd,
count = n;
for (j = 0; plts[j].name != NULL; j++)
- if (plts[j].contents != NULL)
- free (plts[j].contents);
+ free (plts[j].contents);
free (dynrelbuf);
diff --git a/bfd/format.c b/bfd/format.c
index ab98486..e9212bc 100644
--- a/bfd/format.c
+++ b/bfd/format.c
@@ -500,8 +500,7 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
if (abfd->direction == both_direction)
abfd->output_has_begun = TRUE;
- if (matching_vector)
- free (matching_vector);
+ free (matching_vector);
if (preserve_match.marker != NULL)
bfd_preserve_finish (abfd, &preserve_match);
bfd_preserve_finish (abfd, &preserve);
@@ -519,8 +518,7 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
cleanup (abfd);
abfd->xvec = save_targ;
abfd->format = bfd_unknown;
- if (matching_vector)
- free (matching_vector);
+ free (matching_vector);
if (preserve_match.marker != NULL)
bfd_preserve_finish (abfd, &preserve_match);
bfd_preserve_restore (abfd, &preserve);
@@ -544,7 +542,7 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
*(const char **) &matching_vector[match_count] = name;
}
}
- else if (matching_vector)
+ else
free (matching_vector);
if (cleanup)
cleanup (abfd);
diff --git a/bfd/ihex.c b/bfd/ihex.c
index ca36043..4055d47 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -381,8 +381,7 @@ ihex_scan (bfd *abfd)
/* An end record. */
if (abfd->start_address == 0)
abfd->start_address = addr;
- if (buf != NULL)
- free (buf);
+ free (buf);
return TRUE;
case 2:
@@ -474,14 +473,11 @@ ihex_scan (bfd *abfd)
if (error)
goto error_return;
- if (buf != NULL)
- free (buf);
-
+ free (buf);
return TRUE;
error_return:
- if (buf != NULL)
- free (buf);
+ free (buf);
return FALSE;
}
@@ -603,8 +599,7 @@ ihex_read_section (bfd *abfd, asection *section, bfd_byte *contents)
if ((bfd_size_type) (p - contents) >= section->size)
{
/* We've read everything in the section. */
- if (buf != NULL)
- free (buf);
+ free (buf);
return TRUE;
}
@@ -621,14 +616,11 @@ ihex_read_section (bfd *abfd, asection *section, bfd_byte *contents)
goto error_return;
}
- if (buf != NULL)
- free (buf);
-
+ free (buf);
return TRUE;
error_return:
- if (buf != NULL)
- free (buf);
+ free (buf);
return FALSE;
}
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 3579ddb..efe10d2 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -312,7 +312,7 @@ bfd_realloc_or_free (void *ptr, bfd_size_type size)
{
void *ret = bfd_realloc (ptr, size);
- if (ret == NULL && ptr != NULL)
+ if (ret == NULL)
free (ptr);
return ret;
diff --git a/bfd/linker.c b/bfd/linker.c
index 3820ce1..d405746 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -2661,13 +2661,11 @@ default_indirect_link_order (bfd *output_bfd,
new_contents, loc, input_section->size))
goto error_return;
- if (contents != NULL)
- free (contents);
+ free (contents);
return TRUE;
error_return:
- if (contents != NULL)
- free (contents);
+ free (contents);
return FALSE;
}
@@ -2894,10 +2892,8 @@ _bfd_handle_already_linked (asection *sec,
(_("%pB: duplicate section `%pA' has different contents\n"),
sec->owner, sec);
- if (sec_contents)
- free (sec_contents);
- if (l_sec_contents)
- free (l_sec_contents);
+ free (sec_contents);
+ free (l_sec_contents);
}
break;
}
diff --git a/bfd/mmo.c b/bfd/mmo.c
index ea7c4c6..5209736 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -2083,8 +2083,7 @@ mmo_scan (bfd *abfd)
/* Free whatever resources we took. */
for (i = 0; i < sizeof (file_names) / sizeof (file_names[0]); i++)
- if (file_names[i])
- free (file_names[i]);
+ free (file_names[i]);
return ! error;
}
diff --git a/bfd/opncls.c b/bfd/opncls.c
index 78b2ad7..794cf99 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -1162,8 +1162,7 @@ bfd_get_debug_link_info_1 (bfd *abfd, void *crc32_out)
if (!bfd_malloc_and_get_section (abfd, sect, &contents))
{
- if (contents != NULL)
- free (contents);
+ free (contents);
return NULL;
}
@@ -1252,8 +1251,7 @@ bfd_get_alt_debug_link_info (bfd * abfd, bfd_size_type *buildid_len,
if (!bfd_malloc_and_get_section (abfd, sect, & contents))
{
- if (contents != NULL)
- free (contents);
+ free (contents);
return NULL;
}
@@ -1821,8 +1819,7 @@ get_build_id (bfd *abfd)
if (!bfd_malloc_and_get_section (abfd, sect, & contents))
{
- if (contents != NULL)
- free (contents);
+ free (contents);
return NULL;
}
diff --git a/bfd/pdp11.c b/bfd/pdp11.c
index 4555b36..adcf34d 100644
--- a/bfd/pdp11.c
+++ b/bfd/pdp11.c
@@ -2347,8 +2347,7 @@ NAME (aout, find_nearest_line) (bfd *abfd,
else
funclen = strlen (bfd_asymbol_name (func));
- if (adata (abfd).line_buf != NULL)
- free (adata (abfd).line_buf);
+ free (adata (abfd).line_buf);
if (filelen + funclen == 0)
adata (abfd).line_buf = buf = NULL;
else
@@ -2415,7 +2414,7 @@ NAME (aout, bfd_free_cached_info) (bfd *abfd)
if (bfd_get_format (abfd) != bfd_object)
return TRUE;
-#define BFCI_FREE(x) if (x != NULL) { free (x); x = NULL; }
+#define BFCI_FREE(x) do { free (x); x = NULL; } while (0)
BFCI_FREE (obj_aout_symbols (abfd));
#ifdef USE_MMAP
@@ -3914,26 +3913,14 @@ NAME (aout, final_link) (bfd *abfd,
}
}
- if (aout_info.contents != NULL)
- {
- free (aout_info.contents);
- aout_info.contents = NULL;
- }
- if (aout_info.relocs != NULL)
- {
- free (aout_info.relocs);
- aout_info.relocs = NULL;
- }
- if (aout_info.symbol_map != NULL)
- {
- free (aout_info.symbol_map);
- aout_info.symbol_map = NULL;
- }
- if (aout_info.output_syms != NULL)
- {
- free (aout_info.output_syms);
- aout_info.output_syms = NULL;
- }
+ free (aout_info.contents);
+ aout_info.contents = NULL;
+ free (aout_info.relocs);
+ aout_info.relocs = NULL;
+ free (aout_info.symbol_map);
+ aout_info.symbol_map = NULL;
+ free (aout_info.output_syms);
+ aout_info.output_syms = NULL;
if (includes_hash_initialized)
{
bfd_hash_table_free (&aout_info.includes.root);
@@ -3993,14 +3980,10 @@ NAME (aout, final_link) (bfd *abfd,
return TRUE;
error_return:
- if (aout_info.contents != NULL)
- free (aout_info.contents);
- if (aout_info.relocs != NULL)
- free (aout_info.relocs);
- if (aout_info.symbol_map != NULL)
- free (aout_info.symbol_map);
- if (aout_info.output_syms != NULL)
- free (aout_info.output_syms);
+ free (aout_info.contents);
+ free (aout_info.relocs);
+ free (aout_info.symbol_map);
+ free (aout_info.output_syms);
if (includes_hash_initialized)
bfd_hash_table_free (&aout_info.includes.root);
return FALSE;
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 8aa5914..c33c495 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -1343,8 +1343,7 @@ pe_print_idata (bfd * abfd, void * vfile)
if (!bfd_malloc_and_get_section (abfd, rel_section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
@@ -1352,8 +1351,7 @@ pe_print_idata (bfd * abfd, void * vfile)
if (offset >= rel_section->size || offset + 8 > rel_section->size)
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
@@ -1368,8 +1366,7 @@ pe_print_idata (bfd * abfd, void * vfile)
/* xgettext:c-format */
_("\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n"),
start_address, loadable_toc_address, toc_address);
- if (data != NULL)
- free (data);
+ free (data);
}
else
{
@@ -1389,8 +1386,7 @@ pe_print_idata (bfd * abfd, void * vfile)
/* Read the whole section. Some of the fields might be before dataoff. */
if (!bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
@@ -1935,8 +1931,7 @@ pe_print_pdata (bfd * abfd, void * vfile)
if (! bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
@@ -2119,8 +2114,7 @@ _bfd_XX_print_ce_compressed_pdata (bfd * abfd, void * vfile)
if (! bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
@@ -2235,8 +2229,7 @@ pe_print_reloc (bfd * abfd, void * vfile)
if (! bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
@@ -2543,8 +2536,7 @@ rsrc_print_section (bfd * abfd, void * vfile)
if (! bfd_malloc_and_get_section (abfd, section, & data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
@@ -2688,8 +2680,7 @@ pe_print_debugdata (bfd * abfd, void * vfile)
/* Read the whole section. */
if (!bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
@@ -2786,8 +2777,7 @@ pe_is_repro (bfd * abfd)
if (!bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
diff --git a/bfd/pef.c b/bfd/pef.c
index 4e749e1..53958f1 100644
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -505,13 +505,11 @@ bfd_pef_scan_start_address (bfd *abfd)
abfd->start_address = section->vma + header.main_offset;
end:
- if (loaderbuf != NULL)
- free (loaderbuf);
+ free (loaderbuf);
return 0;
error:
- if (loaderbuf != NULL)
- free (loaderbuf);
+ free (loaderbuf);
return -1;
}
@@ -868,18 +866,14 @@ bfd_pef_parse_function_stubs (bfd *abfd,
goto end;
end:
- if (libraries != NULL)
- free (libraries);
- if (imports != NULL)
- free (imports);
+ free (libraries);
+ free (imports);
*nsym = count;
return 0;
error:
- if (libraries != NULL)
- free (libraries);
- if (imports != NULL)
- free (imports);
+ free (libraries);
+ free (imports);
*nsym = count;
return -1;
}
@@ -941,12 +935,8 @@ bfd_pef_parse_symbols (bfd *abfd, asymbol **csym)
csym[count] = NULL;
end:
- if (codebuf != NULL)
- free (codebuf);
-
- if (loaderbuf != NULL)
- free (loaderbuf);
-
+ free (codebuf);
+ free (loaderbuf);
return count;
}
diff --git a/bfd/peicode.h b/bfd/peicode.h
index c5a92af..d851ef8 100644
--- a/bfd/peicode.h
+++ b/bfd/peicode.h
@@ -1133,8 +1133,7 @@ pe_ILF_build_a_bfd (bfd * abfd,
return TRUE;
error_return:
- if (vars.bim->buffer != NULL)
- free (vars.bim->buffer);
+ free (vars.bim->buffer);
free (vars.bim);
return FALSE;
}
@@ -1350,8 +1349,7 @@ pe_bfd_read_buildid (bfd *abfd)
/* Read the whole section. */
if (!bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return;
}
diff --git a/bfd/simple.c b/bfd/simple.c
index 1e320fc..bbdef23 100644
--- a/bfd/simple.c
+++ b/bfd/simple.c
@@ -242,8 +242,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
* saved_offsets.section_count);
if (saved_offsets.sections == NULL)
{
- if (data)
- free (data);
+ free (data);
_bfd_generic_link_hash_table_free (abfd);
abfd->link.next = link_next;
return NULL;
@@ -267,7 +266,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
outbuf,
0,
symbol_table);
- if (contents == NULL && data != NULL)
+ if (contents == NULL)
free (data);
bfd_map_over_sections (abfd, simple_restore_output_info, &saved_offsets);
diff --git a/bfd/som.c b/bfd/som.c
index d36d163..887d9b1 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -2369,20 +2369,13 @@ setup_sections (bfd *abfd,
for (i = 0; i < total_subspaces; i++)
subspace_sections[i]->target_index = i;
- if (space_strings != NULL)
- free (space_strings);
-
- if (subspace_sections != NULL)
- free (subspace_sections);
-
+ free (space_strings);
+ free (subspace_sections);
return TRUE;
error_return:
- if (space_strings != NULL)
- free (space_strings);
-
- if (subspace_sections != NULL)
- free (subspace_sections);
+ free (space_strings);
+ free (subspace_sections);
return FALSE;
}
@@ -4528,12 +4521,11 @@ som_build_and_write_symbol_table (bfd *abfd)
if (bfd_bwrite ((void *) som_symtab, symtab_size, abfd) != symtab_size)
goto error_return;
- if (som_symtab != NULL)
- free (som_symtab);
+ free (som_symtab);
return TRUE;
+
error_return:
- if (som_symtab != NULL)
- free (som_symtab);
+ free (som_symtab);
return FALSE;
}
@@ -4827,15 +4819,12 @@ som_slurp_symbol_table (bfd *abfd)
/* Save our results and return success. */
obj_som_symtab (abfd) = symbase;
successful_return:
- if (buf != NULL)
- free (buf);
+ free (buf);
return (TRUE);
error_return:
- if (symbase != NULL)
- free (symbase);
- if (buf != NULL)
- free (buf);
+ free (symbase);
+ free (buf);
return FALSE;
}
@@ -5230,8 +5219,7 @@ som_set_reloc_info (unsigned char *fixup,
if (!bfd_malloc_and_get_section (section->owner, section,
&contents))
{
- if (contents != NULL)
- free (contents);
+ free (contents);
return (unsigned) -1;
}
section->contents = contents;
@@ -5977,13 +5965,11 @@ som_bfd_count_ar_symbols (bfd *abfd,
(*count)++;
}
}
- if (hash_table != NULL)
- free (hash_table);
+ free (hash_table);
return TRUE;
error_return:
- if (hash_table != NULL)
- free (hash_table);
+ free (hash_table);
return FALSE;
}
@@ -6152,17 +6138,13 @@ som_bfd_fill_in_ar_symbols (bfd *abfd,
}
/* If we haven't died by now, then we successfully read the entire
archive symbol table. */
- if (hash_table != NULL)
- free (hash_table);
- if (som_dict != NULL)
- free (som_dict);
+ free (hash_table);
+ free (som_dict);
return TRUE;
error_return:
- if (hash_table != NULL)
- free (hash_table);
- if (som_dict != NULL)
- free (som_dict);
+ free (hash_table);
+ free (som_dict);
return FALSE;
}
@@ -6611,29 +6593,19 @@ som_bfd_ar_write_symbol_stuff (bfd *abfd,
if (bfd_bwrite ((void *) strings, amt, abfd) != amt)
goto error_return;
- if (hash_table != NULL)
- free (hash_table);
- if (som_dict != NULL)
- free (som_dict);
- if (last_hash_entry != NULL)
- free (last_hash_entry);
- if (lst_syms != NULL)
- free (lst_syms);
- if (strings != NULL)
- free (strings);
+ free (hash_table);
+ free (som_dict);
+ free (last_hash_entry);
+ free (lst_syms);
+ free (strings);
return TRUE;
error_return:
- if (hash_table != NULL)
- free (hash_table);
- if (som_dict != NULL)
- free (som_dict);
- if (last_hash_entry != NULL)
- free (last_hash_entry);
- if (lst_syms != NULL)
- free (lst_syms);
- if (strings != NULL)
- free (strings);
+ free (hash_table);
+ free (som_dict);
+ free (last_hash_entry);
+ free (lst_syms);
+ free (strings);
return FALSE;
}
@@ -6785,7 +6757,7 @@ som_bfd_free_cached_info (bfd *abfd)
{
asection *o;
-#define FREE(x) if (x != NULL) { free (x); x = NULL; }
+#define FREE(x) do { free (x); x = NULL; } while (0)
/* Free the native string and symbol tables. */
FREE (obj_som_symtab (abfd));
FREE (obj_som_stringtab (abfd));
diff --git a/bfd/srec.c b/bfd/srec.c
index 1b3ead8..ef7eb43 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -493,8 +493,7 @@ srec_scan (bfd *abfd)
if (bytes * 2 > bufsize)
{
- if (buf != NULL)
- free (buf);
+ free (buf);
buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
if (buf == NULL)
goto error_return;
@@ -618,9 +617,7 @@ srec_scan (bfd *abfd)
goto error_return;
}
- if (buf != NULL)
- free (buf);
-
+ free (buf);
return TRUE;
}
}
@@ -631,16 +628,12 @@ srec_scan (bfd *abfd)
if (error)
goto error_return;
- if (buf != NULL)
- free (buf);
-
+ free (buf);
return TRUE;
error_return:
- if (symbuf != NULL)
- free (symbuf);
- if (buf != NULL)
- free (buf);
+ free (symbuf);
+ free (buf);
return FALSE;
}
@@ -751,8 +744,7 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
if (bytes * 2 > bufsize)
{
- if (buf != NULL)
- free (buf);
+ free (buf);
buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
if (buf == NULL)
goto error_return;
@@ -768,8 +760,7 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
{
default:
BFD_ASSERT (sofar == section->size);
- if (buf != NULL)
- free (buf);
+ free (buf);
return TRUE;
case '3':
@@ -793,8 +784,7 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
{
/* We've come to the end of this section. */
BFD_ASSERT (sofar == section->size);
- if (buf != NULL)
- free (buf);
+ free (buf);
return TRUE;
}
@@ -817,14 +807,11 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
BFD_ASSERT (sofar == section->size);
- if (buf != NULL)
- free (buf);
-
+ free (buf);
return TRUE;
error_return:
- if (buf != NULL)
- free (buf);
+ free (buf);
return FALSE;
}
diff --git a/bfd/stabs.c b/bfd/stabs.c
index 0e3d062..81ef1de 100644
--- a/bfd/stabs.c
+++ b/bfd/stabs.c
@@ -494,10 +494,8 @@ _bfd_link_section_stabs (bfd *abfd,
return TRUE;
error_return:
- if (stabbuf != NULL)
- free (stabbuf);
- if (stabstrbuf != NULL)
- free (stabstrbuf);
+ free (stabbuf);
+ free (stabstrbuf);
return FALSE;
}
@@ -648,8 +646,7 @@ _bfd_discard_section_stabs (bfd *abfd,
return skip > 0;
error_return:
- if (stabbuf != NULL)
- free (stabbuf);
+ free (stabbuf);
return FALSE;
}
diff --git a/bfd/syms.c b/bfd/syms.c
index 76c2123..b9f7336 100644
--- a/bfd/syms.c
+++ b/bfd/syms.c
@@ -830,8 +830,7 @@ _bfd_generic_read_minisymbols (bfd *abfd,
error_return:
bfd_set_error (bfd_error_no_symbols);
- if (syms != NULL)
- free (syms);
+ free (syms);
return -1;
}
@@ -1054,8 +1053,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
symbols);
if (reloc_count < 0)
{
- if (reloc_vector != NULL)
- free (reloc_vector);
+ free (reloc_vector);
return FALSE;
}
if (reloc_count > 0)
@@ -1086,8 +1084,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
_bfd_error_handler
(_("unsupported .stab relocation"));
bfd_set_error (bfd_error_invalid_operation);
- if (reloc_vector != NULL)
- free (reloc_vector);
+ free (reloc_vector);
return FALSE;
}
@@ -1099,8 +1096,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
}
}
- if (reloc_vector != NULL)
- free (reloc_vector);
+ free (reloc_vector);
/* First time through this function, build a table matching
function VM addresses to stabs, then sort based on starting
diff --git a/bfd/targets.c b/bfd/targets.c
index 9c2db0a..e5fc71a 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -1692,8 +1692,7 @@ bfd_get_target_info (const char *target_name, bfd *abfd,
_bfd_find_arch_match (tname, arches, def_target_arch);
}
- if (arches)
- free (arches);
+ free (arches);
}
return target_vec;
}
diff --git a/bfd/vms-lib.c b/bfd/vms-lib.c
index 6a8a76e..f000bc2 100644
--- a/bfd/vms-lib.c
+++ b/bfd/vms-lib.c
@@ -2045,8 +2045,7 @@ _bfd_vms_lib_build_map (unsigned int nbr_modules,
{
if (storage > syms_max)
{
- if (syms_max > 0)
- free (syms);
+ free (syms);
syms_max = storage;
syms = (asymbol **) bfd_malloc (syms_max);
if (syms == NULL)
@@ -2097,10 +2096,8 @@ _bfd_vms_lib_build_map (unsigned int nbr_modules,
return TRUE;
error_return:
- if (syms_max > 0)
- free (syms);
- if (map != NULL)
- free (map);
+ free (syms);
+ free (map);
return FALSE;
}
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index 503b6ab..4497be2 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -227,8 +227,7 @@ xcoff_get_section_contents (bfd *abfd, asection *sec)
if (! bfd_malloc_and_get_section (abfd, sec, &contents))
{
- if (contents != NULL)
- free (contents);
+ free (contents);
return FALSE;
}
coff_section_data (abfd, sec)->contents = contents;
@@ -2179,7 +2178,6 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
/* If we are not keeping memory, free the reloc information. */
if (! info->keep_memory
&& coff_section_data (abfd, o) != NULL
- && coff_section_data (abfd, o)->relocs != NULL
&& ! coff_section_data (abfd, o)->keep_relocs)
{
free (coff_section_data (abfd, o)->relocs);
@@ -2189,11 +2187,8 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
/* Free up the line numbers. FIXME: We could cache these
somewhere for the final link, to avoid reading them again. */
- if (reloc_info[o->target_index].linenos != NULL)
- {
- free (reloc_info[o->target_index].linenos);
- reloc_info[o->target_index].linenos = NULL;
- }
+ free (reloc_info[o->target_index].linenos);
+ reloc_info[o->target_index].linenos = NULL;
}
free (reloc_info);
@@ -2207,10 +2202,8 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
{
for (o = abfd->sections; o != NULL; o = o->next)
{
- if (reloc_info[o->target_index].csects != NULL)
- free (reloc_info[o->target_index].csects);
- if (reloc_info[o->target_index].linenos != NULL)
- free (reloc_info[o->target_index].linenos);
+ free (reloc_info[o->target_index].csects);
+ free (reloc_info[o->target_index].linenos);
}
free (reloc_info);
}
@@ -2985,7 +2978,6 @@ xcoff_mark (struct bfd_link_info *info, asection *sec)
if (! info->keep_memory
&& coff_section_data (sec->owner, sec) != NULL
- && coff_section_data (sec->owner, sec)->relocs != NULL
&& ! coff_section_data (sec->owner, sec)->keep_relocs)
{
free (coff_section_data (sec->owner, sec)->relocs);
@@ -3971,10 +3963,8 @@ bfd_xcoff_size_dynamic_sections (bfd *output_bfd,
return TRUE;
error_return:
- if (ldinfo.strings != NULL)
- free (ldinfo.strings);
- if (debug_contents != NULL)
- free (debug_contents);
+ free (ldinfo.strings);
+ free (debug_contents);
return FALSE;
}
@@ -6207,31 +6197,16 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
}
/* Free up the buffers used by xcoff_link_input_bfd. */
- if (flinfo.internal_syms != NULL)
- {
- free (flinfo.internal_syms);
- flinfo.internal_syms = NULL;
- }
- if (flinfo.sym_indices != NULL)
- {
- free (flinfo.sym_indices);
- flinfo.sym_indices = NULL;
- }
- if (flinfo.linenos != NULL)
- {
- free (flinfo.linenos);
- flinfo.linenos = NULL;
- }
- if (flinfo.contents != NULL)
- {
- free (flinfo.contents);
- flinfo.contents = NULL;
- }
- if (flinfo.external_relocs != NULL)
- {
- free (flinfo.external_relocs);
- flinfo.external_relocs = NULL;
- }
+ free (flinfo.internal_syms);
+ flinfo.internal_syms = NULL;
+ free (flinfo.sym_indices);
+ flinfo.sym_indices = NULL;
+ free (flinfo.linenos);
+ flinfo.linenos = NULL;
+ free (flinfo.contents);
+ flinfo.contents = NULL;
+ free (flinfo.external_relocs);
+ flinfo.external_relocs = NULL;
/* The value of the last C_FILE symbol is supposed to be -1. Write
it out again. */
@@ -6250,11 +6225,8 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
input files. */
bfd_hash_traverse (&info->hash->table, xcoff_write_global_symbol, &flinfo);
- if (flinfo.outsyms != NULL)
- {
- free (flinfo.outsyms);
- flinfo.outsyms = NULL;
- }
+ free (flinfo.outsyms);
+ flinfo.outsyms = NULL;
/* Now that we have written out all the global symbols, we know the
symbol indices to use for relocs against them, and we can finally
@@ -6336,11 +6308,8 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
goto error_return;
}
- if (external_relocs != NULL)
- {
- free (external_relocs);
- external_relocs = NULL;
- }
+ free (external_relocs);
+ external_relocs = NULL;
/* Free up the section information. */
if (flinfo.section_info != NULL)
@@ -6349,10 +6318,8 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
for (i = 0; i < abfd->section_count; i++)
{
- if (flinfo.section_info[i].relocs != NULL)
- free (flinfo.section_info[i].relocs);
- if (flinfo.section_info[i].rel_hashes != NULL)
- free (flinfo.section_info[i].rel_hashes);
+ free (flinfo.section_info[i].relocs);
+ free (flinfo.section_info[i].rel_hashes);
}
free (flinfo.section_info);
flinfo.section_info = NULL;
@@ -6437,27 +6404,18 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
for (i = 0; i < abfd->section_count; i++)
{
- if (flinfo.section_info[i].relocs != NULL)
- free (flinfo.section_info[i].relocs);
- if (flinfo.section_info[i].rel_hashes != NULL)
- free (flinfo.section_info[i].rel_hashes);
+ free (flinfo.section_info[i].relocs);
+ free (flinfo.section_info[i].rel_hashes);
}
free (flinfo.section_info);
}
- if (flinfo.internal_syms != NULL)
- free (flinfo.internal_syms);
- if (flinfo.sym_indices != NULL)
- free (flinfo.sym_indices);
- if (flinfo.outsyms != NULL)
- free (flinfo.outsyms);
- if (flinfo.linenos != NULL)
- free (flinfo.linenos);
- if (flinfo.contents != NULL)
- free (flinfo.contents);
- if (flinfo.external_relocs != NULL)
- free (flinfo.external_relocs);
- if (external_relocs != NULL)
- free (external_relocs);
+ free (flinfo.internal_syms);
+ free (flinfo.sym_indices);
+ free (flinfo.outsyms);
+ free (flinfo.linenos);
+ free (flinfo.contents);
+ free (flinfo.external_relocs);
+ free (external_relocs);
return FALSE;
}
diff --git a/bfd/xtensa-isa.c b/bfd/xtensa-isa.c
index bc55d71..bbd9124 100644
--- a/bfd/xtensa-isa.c
+++ b/bfd/xtensa-isa.c
@@ -340,43 +340,26 @@ xtensa_isa_free (xtensa_isa isa)
the memory allocated by xtensa_isa_init and restore the xtensa_isa
structure to its initial state. */
- if (intisa->opname_lookup_table)
- {
- free (intisa->opname_lookup_table);
- intisa->opname_lookup_table = 0;
- }
+ free (intisa->opname_lookup_table);
+ intisa->opname_lookup_table = 0;
- if (intisa->state_lookup_table)
- {
- free (intisa->state_lookup_table);
- intisa->state_lookup_table = 0;
- }
+ free (intisa->state_lookup_table);
+ intisa->state_lookup_table = 0;
+
+ free (intisa->sysreg_lookup_table);
+ intisa->sysreg_lookup_table = 0;
- if (intisa->sysreg_lookup_table)
- {
- free (intisa->sysreg_lookup_table);
- intisa->sysreg_lookup_table = 0;
- }
for (n = 0; n < 2; n++)
{
- if (intisa->sysreg_table[n])
- {
- free (intisa->sysreg_table[n]);
- intisa->sysreg_table[n] = 0;
- }
+ free (intisa->sysreg_table[n]);
+ intisa->sysreg_table[n] = 0;
}
- if (intisa->interface_lookup_table)
- {
- free (intisa->interface_lookup_table);
- intisa->interface_lookup_table = 0;
- }
+ free (intisa->interface_lookup_table);
+ intisa->interface_lookup_table = 0;
- if (intisa->funcUnit_lookup_table)
- {
- free (intisa->funcUnit_lookup_table);
- intisa->funcUnit_lookup_table = 0;
- }
+ free (intisa->funcUnit_lookup_table);
+ intisa->funcUnit_lookup_table = 0;
}