public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: cgen@sourceware.org
Subject: Replace "if (x) free (x)" with "free (x)"
Date: Thu, 21 May 2020 10:42:57 +0930	[thread overview]
Message-ID: <20200521011257.GB16548@bubble.grove.modra.org> (raw)

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

             reply	other threads:[~2020-05-21  1:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21  1:12 Alan Modra [this message]
2020-05-21  1:24 ` Frank Ch. Eigler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200521011257.GB16548@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=cgen@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).