Replace "if (x) free (x)" with "free (x)", bfd
authorAlan Modra <amodra@gmail.com>
Wed, 20 May 2020 07:55:20 +0000 (17:25 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 21 May 2020 00:41:57 +0000 (10:11 +0930)
* 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.

79 files changed:
bfd/ChangeLog
bfd/aoutx.h
bfd/archive.c
bfd/bfd.c
bfd/bfdio.c
bfd/coff-alpha.c
bfd/coff-ppc.c
bfd/coff-sh.c
bfd/coff-stgo32.c
bfd/coffcode.h
bfd/coffgen.c
bfd/cofflink.c
bfd/cpu-arm.c
bfd/doc/chew.c
bfd/dwarf2.c
bfd/ecoff.c
bfd/ecofflink.c
bfd/elf-eh-frame.c
bfd/elf-m10200.c
bfd/elf-m10300.c
bfd/elf-strtab.c
bfd/elf.c
bfd/elf32-arc.c
bfd/elf32-arm.c
bfd/elf32-avr.c
bfd/elf32-bfin.c
bfd/elf32-cr16.c
bfd/elf32-crx.c
bfd/elf32-epiphany.c
bfd/elf32-ft32.c
bfd/elf32-h8300.c
bfd/elf32-ip2k.c
bfd/elf32-m32c.c
bfd/elf32-m68hc11.c
bfd/elf32-m68k.c
bfd/elf32-microblaze.c
bfd/elf32-msp430.c
bfd/elf32-nds32.c
bfd/elf32-nios2.c
bfd/elf32-ppc.c
bfd/elf32-pru.c
bfd/elf32-rl78.c
bfd/elf32-rx.c
bfd/elf32-sh.c
bfd/elf32-spu.c
bfd/elf32-v850.c
bfd/elf32-xtensa.c
bfd/elf64-alpha.c
bfd/elf64-hppa.c
bfd/elf64-ia64-vms.c
bfd/elf64-mips.c
bfd/elf64-mmix.c
bfd/elf64-ppc.c
bfd/elf64-sparc.c
bfd/elfcode.h
bfd/elflink.c
bfd/elfnn-ia64.c
bfd/elfnn-riscv.c
bfd/elfxx-mips.c
bfd/elfxx-x86.c
bfd/format.c
bfd/ihex.c
bfd/libbfd.c
bfd/linker.c
bfd/mmo.c
bfd/opncls.c
bfd/pdp11.c
bfd/peXXigen.c
bfd/pef.c
bfd/peicode.h
bfd/simple.c
bfd/som.c
bfd/srec.c
bfd/stabs.c
bfd/syms.c
bfd/targets.c
bfd/vms-lib.c
bfd/xcofflink.c
bfd/xtensa-isa.c

index b3dabb3f33a3993654996887967cb203ce9e7b24..bc51d862ea9151f160281c73c7639c8b0d7fb9aa 100644 (file)
@@ -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
index 4cf5713c355fc3c6b9d6dfee627d759de8a043fb..08083c1555f17ff56a4c20f00d9dde43c7093c4b 100644 (file)
@@ -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;
index 13229777448fe8ee9238eb01c08913e9aeb77c11..9d63849a483d5cd5c5ad40eb6b811bae2c9ae813 100644 (file)
@@ -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);
 
index 84e74a36b838599d5b9e911d449e9892cd34972a..538bdfa5d7df9dfbd3fb1e73bf57e145a4fc543e 100644 (file)
--- 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)
     {
index 0133b76064a6f6c94f4763989799c154e01e756c..5ef3ec493ea5f11665a929d51c23424bd2e31b83 100644 (file)
@@ -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;
 
index 4fd3b5c488dbeec3bcd055ce88316b73bb8232c4..cb52668734460399ae9436e36a89cb8dbbfb3112 100644 (file)
@@ -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;
index bc7118fe051926bf2b63d3b17dc42f3f4eca7d22..a3ad1ef8e6ce877b4c7d9bb189a5ec67475ab203 100644 (file)
@@ -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
index b46a5e34f39f7f9d7d1de5011b188d270dc2a482..0c1061153a8fdde9261af03f406def24d0d0e50d 100644 (file)
@@ -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;
 }
 \f
@@ -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;
 }
 
index 0fea119fc494ddc97ce6044eb07a4c3b893be493..b5e893d771dee2db369b2bf3d7b86d7599e3a16e 100644 (file)
@@ -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;
 }
index c6569ec9cd45ba095ed08d1cbd7f0cdb05b7abcd..9a97ba740f541d38c2b731288947275435b4936d 100644 (file)
@@ -2666,8 +2666,7 @@ coff_write_relocs (bfd * abfd, int first_undef)
        }
 
 #ifdef TARG_AUX
-      if (p != NULL)
-       free (p);
+      free (p);
 #endif
     }
 
index 96140e0ad278d9f7559eaa3e4432bbace5c92231..94589b43d2f0d21d70e4caa87e2fb763cc0c0c28 100644 (file)
@@ -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;
 }
 
index 0beff8397faf0b9ad06fce890c9f16d19a64c0dc..27ac20e80da814065c61f250c0eac5072e7615f5 100644 (file)
@@ -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;
index 903ad847b872d25b2e5d5c6d296c38f278a63662..0b7a8c45580d09f010a1062510fd8b1bf3b5cf4f 100644 (file)
@@ -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;
 }
 
index 31e3e3b93f029c5c52eb406f52957bf3fa125605..76cb09f7cf457f38c31aa492949e95855dadafb9 100644 (file)
@@ -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
index 48b1bdc914a283c78ed63dac04a0f7b80ab655ff..9ed4a4a2871f03bc88c3c132a25453fe8423ba79 100644 (file)
@@ -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;
            }
        }
index 1b0d4233e76be17583ddb8ba383c6406a6b86624..dcded6f4a7e6bf384f311232958b7fbe74ecd11c 100644 (file)
@@ -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;
 }
 \f
@@ -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;
 }
 
index dde5593636acd91acc0afb0590160dd282858296..e7b35f670db2900240c5df8da2e6f0aff4230d49 100644 (file)
@@ -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;
 }
 \f
@@ -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)
index 3cf82d58bcf4ee4cfb9893a7d5ea6908e1879770..7a129b00f8d78fecd8c450ef8aca564eea4a9485 100644 (file)
@@ -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;
 }
 
index 0c8767e3fb128910ce3751014568784d806042b4..58c1515ce89a34936dcd17e26e5ef73c98414bd9 100644 (file)
@@ -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;
 }
index b15af60b978525fa8c5e5504e54215d531f8d1af..696514ab054c64824f6a81392748046b85608d33 100644 (file)
@@ -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;
 }
index 35b821953df67cc503ccb349c054be1afecf6095..a2f4d515d3f63a40e86e0dbc11dbce5232255611 100644 (file)
@@ -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;
index 0211970991c1d6d9ffe5ad3fbd8534acae9cd330..e335ff7efbfd8d19f18dc0c6a44332907ad5ec97 100644 (file)
--- 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;
 }
 \f
index df6e3c4e193ffd9a9a9fadd7ecaedff379a446df..5429a462da070832c105988fcb202362f7a5afa4 100644 (file)
@@ -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;
index 02d43a86195bd527fec24c845c2e925bc5a45346..927a527a6e5ae964e6dd518be715e1af80b233a5 100644 (file)
@@ -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;
index 2a6e743512d7d0e1123eed55b1dab88bff909060..d4ad18c82579f704cda765d65cf4277f3ff07f10 100644 (file)
@@ -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;
 }
index a51a8e8e9f2d9fdf5dc31ca57f3c3654e2ba4063..b06daf507ed7ed5c1764e8a33b2eac3f47816a59 100644 (file)
@@ -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;
 }
index c74cb22618fb01e950aef847e32c2f963d1c2ce3..62906c83a500821dcedbcf367d0338ede5e47146 100644 (file)
@@ -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;
 }
index 1c97dd804242ffe8ab7d161e6d6964392e112877..82f1a3e469033206e943c832bc441ef70b47c81b 100644 (file)
@@ -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;
index c0e3ae5cd28ee258ff12ff95e941350588831690..9e61ed59032e2e926a06ced0d2d639b5d0cf879b 100644 (file)
@@ -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;
 }
index 4a3120b82f6b6da485cbc946b5f2b8d8c7ead91d..78457d533033d85fb3853aec6c98caec0a428975 100644 (file)
@@ -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;
 }
index fdf538d2e8fc3fe7336452984150515f19e21ab2..5488500b1712d685788d2d168da5e196bb531bb9 100644 (file)
@@ -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;
 }
index ca40335cbe953089068884e014f880456ec79c86..c0c8b8ec9a71b2b381ab5e9adf17ab535459b6f8 100644 (file)
@@ -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;
 }
index a357f62b8c215af2dda7590d69456de3207cd416..7a97d6d9092f8a66a62549acafa602840b49866f 100644 (file)
@@ -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;
 }
 
index 46aa43806310de287602041a33c32b52c0c2d068..7bbb48962d2e86f3df36624d342cd6032541140b 100644 (file)
@@ -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;
 }
 
index 5b9d420ded80fd8f044bb0fc53414b34ad40b2a7..868435a444252e7826c139adb096160ec29a331b 100644 (file)
@@ -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;
 }
index bccb0afcf4fa70ccece75802571573dae74352ef..f88da8f6a0c6e57506174105db13f341efabc7b7 100644 (file)
@@ -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;
 }
 
index 9670213b2659e32be713a79483753f74a18ba25a..59e54ecbc9ae8445063290afdbc649fddab40460 100644 (file)
@@ -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;
index a5a681a946d53d51726850c711da57fa29a32d4f..2d26e2ad85d5f1e9a316f62d8588d1e3cbb471bd 100644 (file)
@@ -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)
index bfb6fd16325666ed508be3dff46f009675bf6d0a..0b2e68ebd6905708b6f7cba3954869f669bf9255 100644 (file)
@@ -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;
            }
        }
index 053687c0a2457bb39aae478e239f0e05d732ecb1..a900abe35ef004709f5196d26452641a5a1e925e 100644 (file)
@@ -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;
                  }
index e9063f60fe5e6ff210bdca29b70cdba89cb3e0b3..bc44a1bd12654dad20bf1011154a784fe0738396 100644 (file)
@@ -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;
index 633350faec42d7a07f3972d5f971aba6cbf7ebf9..3929776287fe69b79e11ab7626088a5d9f2fb9d4 100644 (file)
@@ -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;
 }
index 89b7ed50954dc2a8081edbae8819f03909193fe9..3f03ab21f09cf4f7a149232e131a4e60a8886e13 100644 (file)
@@ -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;
 }
index 24203e0d5553b56efc0f380d2c4c58517c15082f..7daf8516c4b1cc494aa5ec731f88ce3067a5bbff 100644 (file)
@@ -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;
 }
index 193438c7979e1b523cb10fd88251a1996167995e..dcdee26082536ea9c389bd5e571b5fd5a160edc3 100644 (file)
@@ -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;
index bf37a936620f12a3c6482d265ae2a7e2c6ae09d5..0235044d2de47d79b06b1c656da6e5b7fdab6688 100644 (file)
@@ -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;
index 4327b027911ff251c422db28aeef05d527416426..05c4f8430a2046a9c48546c815f0eb2ebdb2f728 100644 (file)
@@ -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);
index 8f73212dae660c599e2293ceb48dfd3cf22beb39..4e4efae0b1bf2d76980d7f51a6a4183674d3e1de 100644 (file)
@@ -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;
 }
index 0fdbea45cce5e8cf9912d5e3b441c91c23f53ff0..7fc2dc0e0c1384babf3b7eee1c56c1a735d40dbc 100644 (file)
@@ -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)
index 6fa116f610eea6cd59e36f8e94cfca8f9e495f59..a97858ebfbe8af1ac31f0f822b2ce3c14d2143f4 100644 (file)
@@ -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;
 }
index 413018fcf3e35b041c3a6b408935a92d61d807e9..a07c39f1fd13df86314540945c8998c7bd8a8e91 100644 (file)
@@ -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;
 }
 
index 2c936badf541fab0d48b39d40e2c6827cd23959a..fee4a0fbd78c778b2d63bb2c6c10b98a7680fcab 100644 (file)
@@ -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;
 }
index da4a8c7377741a51f169a16158490b271214a70c..bbd8aee4f9679e66a48d55e01cba5eea8d3b67ae 100644 (file)
@@ -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)
index f07c06222ad6d902f15cf0c83601795decc3dba1..8d352252b63aba8278f8764f5e4d746e1edf5b5e 100644 (file)
@@ -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;
 }
 
index 5e6b2a430f8fe110d152a457b402f8073eb0fb28..2e2c5343f2ce5f1727dc64161f710e47d7296dae 100644 (file)
@@ -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;
 }
 
index 90ada7a1cca0142a2dec682b11d1babd4fd91d82..c157aea90dc527e3625a831c8d85ba505a2e34de 100644 (file)
@@ -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);
 }
 
index 0cdd6b58c9dc4e7141ceaa6c1da929c766e61f76..d179bc45686b708d4a6420ac8a0ad8455a2c01ad 100644 (file)
@@ -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;
 }
index e8e377e32572237b107ec92ecbfd856ef31da95b..5fa6e35d06125a4ab3303f47c55a625f96718204 100644 (file)
@@ -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.  */
index 9ce205e9cf66c2f81f9601479c29f33f8b441857..e563d56dbbedf96d38f0f388bef8a5b894c804d1 100644 (file)
@@ -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;
 }
 \f
@@ -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;
 }
 \f
@@ -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;
 }
 \f
@@ -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;
index 0fc75fbedfb7f6086b0c803dcc2f4b01de76a7fc..9679dca981e77923e7ad2c0bccd5bdb827cba6e5 100644 (file)
@@ -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);
 
index ab98486fb4526919ffbaeddc3d1c76d331ff3606..e9212bc6f2498c0277e69d6500ccfcdfb54c964b 100644 (file)
@@ -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);
index ca36043fe2daf48d8e7c68249f1df2311cdb9f37..4055d47e3d9efdcd1b0c594f91b7e0ced090277b 100644 (file)
@@ -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;
 }
 
index 3579ddb855a643da28c0edf59b43399da324f894..efe10d22e8903ff257eb02b081bb2f4c927bc7ad 100644 (file)
@@ -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;
index 3820ce14f83a7b2f591d8b7b0ee9dfa0025791f5..d4057461a3f4a358f138f3d1b74694160e3c553a 100644 (file)
@@ -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;
     }
index ea7c4c66b549e519915442dbe853848af9c55dfc..5209736a50540b2edc67435ff4bebf3cf2063ae7 100644 (file)
--- 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;
 }
 
index 78b2ad7dd759abc72776fa3375c0d8e9462a4925..794cf99e7cefac87f9d04e93ef7ef443741da457 100644 (file)
@@ -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;
     }
 
index 4555b36d274cf5d228e8b06e3eefb3416d4a4f63..adcf34da1deca84e19a3c454812f5231b733a844 100644 (file)
@@ -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;
index 8aa5914acd93845e27b1362af22093b0866ee269..c33c495a0f6a4e4ac741d0b77d7a50a7e1c721a1 100644 (file)
@@ -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;
     }
 
index 4e749e1949789946e540420920be43a940d5118d..53958f12400ecb2694b8daba8c3cad1b9f8f243e 100644 (file)
--- 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;
 }
 
index c5a92afefc4604b29c92a2ac0f56dbc4a4546df9..d851ef8db82c4e70aac8ab5aaa1006a6094f85b1 100644 (file)
@@ -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;
     }
 
index 1e320fc391754b758010dc4919fdd6e0cdb20d83..bbdef23a140d623631614ded8eb88723c28fae3c 100644 (file)
@@ -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);
index d36d163bb6b11910325c0581d9f1ad28fbab6045..887d9b187ef88b2b9d255f4243d3bf1cb4995325 100644 (file)
--- 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));
index 1b3ead81b23f0df8919fd8aa2e31670d11d023e2..ef7eb43995902693aaf410373e327da178973b6b 100644 (file)
@@ -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;
 }
 
index 0e3d0622b4d7ae8fe7b6136cdcef818fe7a71a0d..81ef1deb4a6ad589f0b38e4bacef31a7f955af65 100644 (file)
@@ -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;
 }
 \f
@@ -648,8 +646,7 @@ _bfd_discard_section_stabs (bfd *abfd,
   return skip > 0;
 
  error_return:
-  if (stabbuf != NULL)
-    free (stabbuf);
+  free (stabbuf);
   return FALSE;
 }
 
index 76c212344eb8631cdec209cc1223863ee84a6daa..b9f73361e6d314e6dc92a2adce1b9580757f9c27 100644 (file)
@@ -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
index 9c2db0aeb65293fe6dd259d8c216760830dc710a..e5fc71a206ab59ee7cfe4fcad6fb594d3707b634 100644 (file)
@@ -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;
 }
index 6a8a76ecb034bb9b155dee595d07ca658e2c0ba6..f000bc2a8f1fbf08fd9db209a0d872deb8090dc0 100644 (file)
@@ -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;
 }
 
index 503b6ab93f1ed2fc760556a9da09008b3a7ea3a8..4497be25291b7c278c76f520f7df9f3fe40cf11b 100644 (file)
@@ -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;
 }
index bc55d71360ff5339183e852d3b0529e96c348756..bbd9124902437e15e4ff0820b324399078c2f4f8 100644 (file)
@@ -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;
 }
 
 
This page took 0.100757 seconds and 4 git commands to generate.