diff options
author | Alan Modra <amodra@gmail.com> | 2020-05-20 17:25:20 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-05-21 10:11:57 +0930 |
commit | c95949892f6f1e2974a0fb8a5463d7b6432ac469 (patch) | |
tree | 787ac00de8dc1bfb5170e2b2caf05e66d8ab6c7f /bfd/xcofflink.c | |
parent | c31ab5a0010ac9e3d31fd218fffcff1b9696363e (diff) | |
download | binutils-c95949892f6f1e2974a0fb8a5463d7b6432ac469.zip binutils-c95949892f6f1e2974a0fb8a5463d7b6432ac469.tar.gz binutils-c95949892f6f1e2974a0fb8a5463d7b6432ac469.tar.bz2 |
Replace "if (x) free (x)" with "free (x)", bfd
* 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.
Diffstat (limited to 'bfd/xcofflink.c')
-rw-r--r-- | bfd/xcofflink.c | 106 |
1 files changed, 32 insertions, 74 deletions
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; } |