[binutils-gdb] BFD: Remove null pointer checks for `bfd_hash_table_free' calls
Maciej W. Rozycki
macro@sourceware.org
Tue Jan 20 15:30:42 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b3dcdde51b00104a768b27bb5613dd763186f356
commit b3dcdde51b00104a768b27bb5613dd763186f356
Author: Maciej W. Rozycki <macro@redhat.com>
Date: Tue Jan 20 15:29:15 2026 +0000
BFD: Remove null pointer checks for `bfd_hash_table_free' calls
Given that as from commit 90e5645309be ("libiberty: Make `objalloc_free'
`free'-like WRT null pointer") `bfd_hash_table_free' now returns with no
action taken when called for a hash table with no allocation present,
remove null pointer checks guarding invocations.
Diff:
---
bfd/opncls.c | 6 ++----
binutils/wrstabs.c | 6 ++----
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/bfd/opncls.c b/bfd/opncls.c
index 2ef820ffdb7..624c958febf 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -151,8 +151,7 @@ _bfd_delete_bfd (bfd *abfd)
bfd_free_cached_info (abfd);
/* The target _bfd_free_cached_info may not have done anything.. */
- if (abfd->section_htab.memory)
- bfd_hash_table_free (&abfd->section_htab);
+ bfd_hash_table_free (&abfd->section_htab);
if (abfd->memory)
objalloc_free (abfd->memory);
@@ -186,8 +185,7 @@ DESCRIPTION
bool
_bfd_free_cached_info (bfd *abfd)
{
- if (abfd->section_htab.memory)
- bfd_hash_table_free (&abfd->section_htab);
+ bfd_hash_table_free (&abfd->section_htab);
abfd->sections = NULL;
abfd->section_last = NULL;
diff --git a/binutils/wrstabs.c b/binutils/wrstabs.c
index dad2ca8b690..8e17ff7a12f 100644
--- a/binutils/wrstabs.c
+++ b/binutils/wrstabs.c
@@ -555,10 +555,8 @@ write_stabs_in_sections_debugging_info (bfd *abfd, void *dhandle,
free (info.type_cache.function_types);
free (info.type_cache.reference_types);
free (info.type_cache.struct_types);
- if (info.typedef_hash.table.memory)
- bfd_hash_table_free (&info.typedef_hash.table);
- if (info.strhash.table.memory)
- bfd_hash_table_free (&info.strhash.table);
+ bfd_hash_table_free (&info.typedef_hash.table);
+ bfd_hash_table_free (&info.strhash.table);
return ret;
}
More information about the Binutils-cvs
mailing list