public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* Replace "if (x) free (x)" with "free (x)"
@ 2020-05-21  1:12 Alan Modra
  2020-05-21  1:24 ` Frank Ch. Eigler
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Modra @ 2020-05-21  1:12 UTC (permalink / raw)
  To: cgen

Most younger programmers have never heard of a libc "free"
implementation that didn't simply return without doing anything when
passed a NULL pointer, and think it weird that old fossils still write
code that tests for NULL before calling free.  I've been going through
the binutils source removing these unnecessary tests.  This cleans up
some generated files in opcodes/.  OK to apply?

	* desc-cpu.scm (@arch@_cgen_cpu_close): Free without first
	checking for non-NULL.

diff --git a/desc-cpu.scm b/desc-cpu.scm
index b24c9f2..5bf5bc7 100644
--- a/desc-cpu.scm
+++ b/desc-cpu.scm
@@ -918,18 +918,10 @@ void
 	  regfree (CGEN_INSN_RX (insns));
     }  
 
-  if (cd->macro_insn_table.init_entries)
-    free ((CGEN_INSN *) cd->macro_insn_table.init_entries);
-
-  if (cd->insn_table.init_entries)
-    free ((CGEN_INSN *) cd->insn_table.init_entries);
-
-  if (cd->hw_table.entries)
-    free ((CGEN_HW_ENTRY *) cd->hw_table.entries);
-
-  if (cd->operand_table.entries)
-    free ((CGEN_HW_ENTRY *) cd->operand_table.entries);
-
+  free ((CGEN_INSN *) cd->macro_insn_table.init_entries);
+  free ((CGEN_INSN *) cd->insn_table.init_entries);
+  free ((CGEN_HW_ENTRY *) cd->hw_table.entries);
+  free ((CGEN_HW_ENTRY *) cd->operand_table.entries);
   free (cd);
 }
 

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-21  1:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21  1:12 Replace "if (x) free (x)" with "free (x)" Alan Modra
2020-05-21  1:24 ` Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).