From 84d53fa9d281f057af5916f8663bc9a2872c5f6e Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 21 May 2020 13:12:29 -0400 Subject: gdb: remove unnecessary NULL checks before xfree I was inspired by a series of patches merged by Alan Modra in the other projects, so I did the same in GDB with a bit of Coccinelle and grep. This patch removes the unnecessary NULL checks before calls to xfree. They are unnecessary because xfree already does a NULL check. Since free is supposed to handle NULL values correctly, the NULL check in xfree itself is also questionable, but I've left it there for now. gdb/ChangeLog: * coffread.c (patch_type): Remove NULL check before xfree. * corefile.c (set_gnutarget): Likewise. * cp-abi.c (set_cp_abi_as_auto_default): Likewise. * exec.c (build_section_table): Likewise. * remote.c (remote_target::pass_signals): Likewise. * utils.c (n_spaces): Likewise. * cli/cli-script.c (document_command): Likewise. * i386-windows-tdep.c (core_process_module_section): Likewise. * linux-fork.c (struct fork_info) <~fork_info>: Likewise. --- gdb/exec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gdb/exec.c') diff --git a/gdb/exec.c b/gdb/exec.c index 93dd157..14c7749 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -648,8 +648,7 @@ build_section_table (struct bfd *some_bfd, struct target_section **start, unsigned count; count = bfd_count_sections (some_bfd); - if (*start) - xfree (* start); + xfree (*start); *start = XNEWVEC (struct target_section, count); *end = *start; bfd_map_over_sections (some_bfd, add_to_section_table, (char *) end); -- cgit v1.1