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.
This commit is contained in:
Simon Marchi 2020-05-21 13:12:29 -04:00
parent 0490dd41ae
commit 84d53fa9d2
11 changed files with 24 additions and 22 deletions

View file

@ -1528,8 +1528,7 @@ document_command (const char *comname, int from_tty)
counted_command_line doclines = read_command_lines (prompt.c_str (),
from_tty, 0, 0);
if (c->doc)
xfree ((char *) c->doc);
xfree ((char *) c->doc);
{
struct command_line *cl1;