Patchwork avoid useless if-before-free tests

login
register
mail settings
Submitter Jim Meyering
Date March 5, 2011, 2:05 p.m.
Message ID <87zkp9zmq0.fsf@rho.meyering.net>
Download mbox | patch
Permalink /patch/85525/
State New
Headers show

Comments

Jim Meyering - March 5, 2011, 2:05 p.m.
Hello,

Someone asked me about this yesterday, and since I've been carrying
this patch series for over a year -- it's not high priority --
this seems like a good time finally to post it.

I've been removing if-before-free tests for a few years now.
Here are some of the projects that have endured this janitorial work:
  git
  emacs
  glibc
  gnulib
  coreutils
  freeIPA
  libvirt
  util-linux-ng
  idutils
  openais
  corosync

Over the course of those adventures, there has been plenty
of discussion.  If you'd like links with justification, I
can provide several.

When I started, I wrote a script to automate the process.
Then I realized that coccinelle's spatch could do it, too, and more
cleanly.  Here's the script I use:
  http://git.sv.gnu.org/cgit/gnulib.git/tree/build-aux/useless-if-before-free
Some projects run it via a "make syntax-check" rule that ensures no
new offending test is introduced (see gnulib's maint.mk).

Here's what I've done, to see if you're ok with it in principle.
If so, let me know and I'll be happy to add proper ChangeLog entries.

The 4th patch merely fixes a syntax error introduced by the
transformation of the 3rd.  For the sake of bisection, at least
those two should be combined.  I'm all for combining all four,
if you prefer.


From 0c74949d030103a9c33caaf5d753fe1bfe5792a5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Mon, 3 Jan 2011 16:52:37 +0100
Subject: [PATCH 1/4] don't encourage unnecessary use of if before free

* README.Portability: Don't encourage people to write
"if (foo) free (foo)".
---
 gcc/README.Portability |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)

--
1.7.4.1.21.g4cc62
Joseph S. Myers - March 5, 2011, 7:16 p.m.
On Sat, 5 Mar 2011, Jim Meyering wrote:

> diff --git a/gcc/config/i386/gmm_malloc.h b/gcc/config/i386/gmm_malloc.h
> index 7a7e840..8993fc7 100644
> --- a/gcc/config/i386/gmm_malloc.h
> +++ b/gcc/config/i386/gmm_malloc.h
> @@ -67,8 +67,7 @@ _mm_malloc (size_t size, size_t align)
>  static __inline__ void
>  _mm_free (void * aligned_ptr)
>  {
> -  if (aligned_ptr)
> -    free (((void **) aligned_ptr) [-1]);
> +  free (((void **) aligned_ptr) [-1]);
>  }

This one looks suspicious; it's not if (p) free (p); but if (p) free 
(something-derived-from-p);.

> diff --git a/libjava/classpath/native/fdlibm/dtoa.c b/libjava/classpath/native/fdlibm/dtoa.c
> index 458e629..92aa793 100644

http://gcc.gnu.org/codingconventions.html says Classpath changes should go 
via Classpath upstream, not directly into GCC.  I don't know if that's 
still accurate.

> diff --git a/zlib/contrib/minizip/unzip.c b/zlib/contrib/minizip/unzip.c
> index 9ad4766..644ef1b 100644

We definitely don't want to make local changes to zlib for this sort of 
issue, though importing a new upstream version of zlib (making sure the 
local configure code still works) should be fine for 4.7.
Joseph S. Myers - March 5, 2011, 7:19 p.m.
On Sat, 5 Mar 2011, Jim Meyering wrote:

> diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c
> index 6faac57..ba3cc9a 100644

Sorry, missed these in the first pass; intl/ is another case where we 
wouldn't want to patch this locally.  An import of updated libintl from 
newer upstream gettext would be fine for 4.7, with local changes merged as 
needed, but may be quite involved given how old the present copy is.
Dr Andrew John Hughes - March 7, 2011, 7:52 p.m.
On 19:16 Sat 05 Mar     , Joseph S. Myers wrote:
> On Sat, 5 Mar 2011, Jim Meyering wrote:
> 
> > diff --git a/gcc/config/i386/gmm_malloc.h b/gcc/config/i386/gmm_malloc.h
> > index 7a7e840..8993fc7 100644
> > --- a/gcc/config/i386/gmm_malloc.h
> > +++ b/gcc/config/i386/gmm_malloc.h
> > @@ -67,8 +67,7 @@ _mm_malloc (size_t size, size_t align)
> >  static __inline__ void
> >  _mm_free (void * aligned_ptr)
> >  {
> > -  if (aligned_ptr)
> > -    free (((void **) aligned_ptr) [-1]);
> > +  free (((void **) aligned_ptr) [-1]);
> >  }
> 
> This one looks suspicious; it's not if (p) free (p); but if (p) free 
> (something-derived-from-p);.
> 
> > diff --git a/libjava/classpath/native/fdlibm/dtoa.c b/libjava/classpath/native/fdlibm/dtoa.c
> > index 458e629..92aa793 100644
> 
> http://gcc.gnu.org/codingconventions.html says Classpath changes should go 
> via Classpath upstream, not directly into GCC.  I don't know if that's 
> still accurate.
> 

That's still true.  This seems to be the first message I've received in this
thread, so I'm not even aware of what these changes are.  Were the earlier
messages not sent to this list?

> > diff --git a/zlib/contrib/minizip/unzip.c b/zlib/contrib/minizip/unzip.c
> > index 9ad4766..644ef1b 100644
> 
> We definitely don't want to make local changes to zlib for this sort of 
> issue, though importing a new upstream version of zlib (making sure the 
> local configure code still works) should be fine for 4.7.
> 
> -- 
> Joseph S. Myers
> joseph@codesourcery.com
Joseph S. Myers - March 7, 2011, 10:47 p.m.
On Mon, 7 Mar 2011, Dr Andrew John Hughes wrote:

> > http://gcc.gnu.org/codingconventions.html says Classpath changes should go 
> > via Classpath upstream, not directly into GCC.  I don't know if that's 
> > still accurate.
> > 
> 
> That's still true.  This seems to be the first message I've received in this
> thread, so I'm not even aware of what these changes are.  Were the earlier
> messages not sent to this list?

The original patch went only to gcc-patches.

http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00252.html
Paolo Carlini - March 7, 2011, 10:56 p.m.
On 03/05/2011 03:05 PM, Jim Meyering wrote:
> diff --git a/libstdc++-v3/libsupc++/del_opnt.cc b/libstdc++-v3/libsupc++/del_opnt.cc
> index 75051d5..29eab10 100644
> --- a/libstdc++-v3/libsupc++/del_opnt.cc
> +++ b/libstdc++-v3/libsupc++/del_opnt.cc
> @@ -31,6 +31,5 @@ extern "C" void free (void *);
>  _GLIBCXX_WEAK_DEFINITION void
>  operator delete (void *ptr, const std::nothrow_t&) throw ()
>  {
> -  if (ptr)
> -    free (ptr);
> +  free (ptr);
>  }
>   
This is Ok,

Thanks,
Paolo.
Jim Meyering - March 8, 2011, 10:45 a.m.
Joseph S. Myers wrote:

Thank you for the prompt feedback.

> On Sat, 5 Mar 2011, Jim Meyering wrote:
>
>> diff --git a/gcc/config/i386/gmm_malloc.h b/gcc/config/i386/gmm_malloc.h
>> index 7a7e840..8993fc7 100644
>> --- a/gcc/config/i386/gmm_malloc.h
>> +++ b/gcc/config/i386/gmm_malloc.h
>> @@ -67,8 +67,7 @@ _mm_malloc (size_t size, size_t align)
>>  static __inline__ void
>>  _mm_free (void * aligned_ptr)
>>  {
>> -  if (aligned_ptr)
>> -    free (((void **) aligned_ptr) [-1]);
>> +  free (((void **) aligned_ptr) [-1]);
>>  }
>
> This one looks suspicious; it's not if (p) free (p); but if (p) free
> (something-derived-from-p);.

Good catch.  That is an invalid transformation.  I've reverted it.
It is also the first one like that that I've seen.
Calling free (((void **) 0) [-1]); would not go down well.

>> diff --git a/libjava/classpath/native/fdlibm/dtoa.c
>> b/libjava/classpath/native/fdlibm/dtoa.c
>> index 458e629..92aa793 100644
>
> http://gcc.gnu.org/codingconventions.html says Classpath changes should go
> via Classpath upstream, not directly into GCC.  I don't know if that's
> still accurate.

Thanks for the tip and for Cc'ing java-patches.
I've omitted the classpath/ changes.

>> diff --git a/zlib/contrib/minizip/unzip.c b/zlib/contrib/minizip/unzip.c
>> index 9ad4766..644ef1b 100644
>
> We definitely don't want to make local changes to zlib for this sort of
> issue, though importing a new upstream version of zlib (making sure the
> local configure code still works) should be fine for 4.7.

I've also omitted zlib/ and intl/ changes.

Is libgo/ in the same boat?  Only one of its files is affected, but
I found no ChangeLog for libgo and no libgo-related ChangeLog entries.
I could always add an entry at the top,

   * libgo/runtime/go-select.c (__go_select): ...
Jeff Law - March 8, 2011, 4:34 p.m.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 03/05/11 07:05, Jim Meyering wrote:
> Hello,
> 
> Someone asked me about this yesterday, and since I've been carrying
> this patch series for over a year -- it's not high priority --
> this seems like a good time finally to post it.
> 
> I've been removing if-before-free tests for a few years now.
> Here are some of the projects that have endured this janitorial work:
You know, it probably wouldn't be that hard to have GCC perform this
analysis for you using its dataflow framework.  Checking for a free call
which is dominated by a test if the argument is null would be a pretty
simple check.

Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNdlqeAAoJEBRtltQi2kC746gIAImSP5BZAQ/d9wF94EQcBsWQ
Qo4hn+LK6G2h5R2yVwB9dMf4CTZygxnowlFTxtG9QXMlzMCQp61jHJNLJLpgY4Qz
HLMjPGS8uMUa28pJkeRU0ZIMy5hDGID24F0FChnrpNalBnlCvP0xXsnZEcXi8Ei2
3VkOMx87MAnVT0k7omZSnMy2HeKqmnP9xQMGM+ISEAFJuiGYeb5Os3T7IRprJjia
DSOjSF20O8TTV6543pUrMvdzrEYtTTmsv1UKejiyGMDpHrs2qNHsyqiFBO/FLGLA
bdNplowv5xTTrlPy/4zYXewvl3XLr8okrk8/c0Y4dIKq/g5jIB6pYVXilGSOVa0=
=WHAM
-----END PGP SIGNATURE-----
Dr Andrew John Hughes - March 8, 2011, 4:56 p.m.
On 22:47 Mon 07 Mar     , Joseph S. Myers wrote:
> On Mon, 7 Mar 2011, Dr Andrew John Hughes wrote:
> 
> > > http://gcc.gnu.org/codingconventions.html says Classpath changes should go 
> > > via Classpath upstream, not directly into GCC.  I don't know if that's 
> > > still accurate.
> > > 
> > 
> > That's still true.  This seems to be the first message I've received in this
> > thread, so I'm not even aware of what these changes are.  Were the earlier
> > messages not sent to this list?
> 
> The original patch went only to gcc-patches.
> 
> http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00252.html
> 

Thanks for the link.

I'd like some explanation of why these changes are necessary before we start
adding them to Classpath.  Are we just assuming that all free implementations
will ignore NULL now?

With regards to fdlibm, there is a further upstream for this where
these changes should be made first.  fdlibm is also used by OpenJDK.

> -- 
> Joseph S. Myers
> joseph@codesourcery.com
Jim Meyering - March 8, 2011, 5:17 p.m.
Dr Andrew John Hughes wrote:
> On 22:47 Mon 07 Mar     , Joseph S. Myers wrote:
>> On Mon, 7 Mar 2011, Dr Andrew John Hughes wrote:
>>
>> > > http://gcc.gnu.org/codingconventions.html says Classpath changes should go
>> > > via Classpath upstream, not directly into GCC.  I don't know if that's
>> > > still accurate.
>> > >
>> >
>> > That's still true.  This seems to be the first message I've received in this
>> > thread, so I'm not even aware of what these changes are.  Were the earlier
>> > messages not sent to this list?
>>
>> The original patch went only to gcc-patches.
>>
>> http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00252.html
>>
>
> Thanks for the link.
>
> I'd like some explanation of why these changes are necessary before we start
> adding them to Classpath.  Are we just assuming that all free implementations
> will ignore NULL now?

IMHO, they're not officially "necessary", but rather nice to have,
since they eliminate code that is now obviously obsolete.
Those tests have been unnecessary for at least 5 years.
The efficiency (of removing the redundant test) is never the
issue for me, personally.  My main argument for making the change
is improved maintainability/readability:

  - less logic (esp. when the expression is more complicated)
  - no surprise (for reviewers who stopped using such tests years ago)
  - more compact, so more lines fit on a page/screen
  - removing unused code is always worthwhile

Sort of along the same lines as removing anachronistic casts of
malloc/calloc/realloc return values in C code.  No longer needed,
but many people continue to use them for no good reason.
Richard Guenther - March 9, 2011, 9:38 a.m.
On Tue, Mar 8, 2011 at 5:34 PM, Jeff Law <law@redhat.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 03/05/11 07:05, Jim Meyering wrote:
>> Hello,
>>
>> Someone asked me about this yesterday, and since I've been carrying
>> this patch series for over a year -- it's not high priority --
>> this seems like a good time finally to post it.
>>
>> I've been removing if-before-free tests for a few years now.
>> Here are some of the projects that have endured this janitorial work:
> You know, it probably wouldn't be that hard to have GCC perform this
> analysis for you using its dataflow framework.  Checking for a free call
> which is dominated by a test if the argument is null would be a pretty
> simple check.

Yeah, I did this for the malloc hoisting patches first but then settled
on changing the Fortran frontend to not emit a NULL test (which it still
does, the patches were not merged).

Richard.

> Jeff
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJNdlqeAAoJEBRtltQi2kC746gIAImSP5BZAQ/d9wF94EQcBsWQ
> Qo4hn+LK6G2h5R2yVwB9dMf4CTZygxnowlFTxtG9QXMlzMCQp61jHJNLJLpgY4Qz
> HLMjPGS8uMUa28pJkeRU0ZIMy5hDGID24F0FChnrpNalBnlCvP0xXsnZEcXi8Ei2
> 3VkOMx87MAnVT0k7omZSnMy2HeKqmnP9xQMGM+ISEAFJuiGYeb5Os3T7IRprJjia
> DSOjSF20O8TTV6543pUrMvdzrEYtTTmsv1UKejiyGMDpHrs2qNHsyqiFBO/FLGLA
> bdNplowv5xTTrlPy/4zYXewvl3XLr8okrk8/c0Y4dIKq/g5jIB6pYVXilGSOVa0=
> =WHAM
> -----END PGP SIGNATURE-----
>

Patch

diff --git a/gcc/README.Portability b/gcc/README.Portability
index 32a33e2..c4a485f 100644
--- a/gcc/README.Portability
+++ b/gcc/README.Portability
@@ -51,16 +51,6 @@  foo (bar, )
 needs to be coded in some other way.


-free and realloc
-----------------
-
-Some implementations crash upon attempts to free or realloc the null
-pointer.  Thus if mem might be null, you need to write
-
-  if (mem)
-    free (mem);
-
-
 Trigraphs
 ---------

--
1.7.4.1.21.g4cc62


From 6cea681646b53decf2feb9797be8df28e2e33d0a Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Mon, 3 Jan 2011 16:54:55 +0100
Subject: [PATCH 2/4] remove unnecessary if-before-free tests

git grep -l -z "$free *(" | xargs -0 useless-if-before-free -l --name="$free" \
  | xargs -0 perl -0x3b -pi -e
     's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s+('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\))/$2/s'
---
 gcc/ada/initialize.c                               |    3 +-
 gcc/c-family/c-format.c                            |    6 +-
 gcc/calls.c                                        |   15 +---
 gcc/cfgcleanup.c                                   |    3 +-
 gcc/collect2.c                                     |    3 +-
 gcc/config/i386/gmm_malloc.h                       |    3 +-
 gcc/config/i386/i386.c                             |    3 +-
 gcc/config/mcore/mcore.c                           |    3 +-
 gcc/coverage.c                                     |    3 +-
 gcc/cp/tree.c                                      |    3 +-
 gcc/cse.c                                          |    6 +-
 gcc/cselib.c                                       |    3 +-
 gcc/df-core.c                                      |   15 +---
 gcc/fortran/gfortranspec.c                         |    3 +-
 gcc/function.c                                     |    3 +-
 gcc/gcc.c                                          |   15 +---
 gcc/gcov.c                                         |    6 +-
 gcc/gensupport.c                                   |   12 +--
 gcc/graphite-clast-to-gimple.c                     |    3 +-
 gcc/graphite-sese-to-poly.c                        |    3 +-
 gcc/haifa-sched.c                                  |    3 +-
 gcc/ipa-prop.c                                     |    3 +-
 gcc/ipa-pure-const.c                               |    3 +-
 gcc/ipa-reference.c                                |    3 +-
 gcc/ira-costs.c                                    |   15 +---
 gcc/ira.c                                          |    9 +--
 gcc/java/jcf-parse.c                               |    3 +-
 gcc/matrix-reorg.c                                 |    9 +--
 gcc/prefix.c                                       |    3 +-
 gcc/profile.c                                      |    3 +-
 gcc/reload1.c                                      |   12 +--
 gcc/sched-deps.c                                   |    3 +-
 gcc/sel-sched-ir.c                                 |    3 +-
 gcc/sese.c                                         |    6 +-
 gcc/tree-data-ref.c                                |    6 +-
 gcc/tree-eh.c                                      |    3 +-
 gcc/tree-ssa-coalesce.c                            |    3 +-
 gcc/tree-ssa-live.c                                |    6 +-
 gcc/tree-ssa-loop-ivopts.c                         |    6 +-
 gcc/tree-ssa-pre.c                                 |    3 +-
 intl/bindtextdom.c                                 |    3 +-
 intl/loadmsgcat.c                                  |    6 +-
 intl/localcharset.c                                |    3 +-
 libcpp/files.c                                     |    3 +-
 libcpp/init.c                                      |    3 +-
 libcpp/macro.c                                     |    3 +-
 libcpp/pch.c                                       |    9 +--
 libdecnumber/decNumber.c                           |   80 ++++++++++----------
 libgfortran/intrinsics/move_alloc.c                |    3 +-
 libgfortran/io/fbuf.c                              |    3 +-
 libgfortran/io/format.c                            |    3 +-
 libgfortran/io/open.c                              |    3 +-
 libgfortran/io/unit.c                              |    9 +--
 libgfortran/io/unix.c                              |    3 +-
 libgo/runtime/go-select.c                          |    6 +-
 libiberty/cp-demint.c                              |    6 +-
 libiberty/cplus-dem.c                              |    3 +-
 libiberty/pex-common.c                             |    9 +--
 libiberty/pex-msdos.c                              |    6 +-
 libiberty/pex-win32.c                              |   24 ++----
 libiberty/regex.c                                  |   11 +--
 libjava/classpath/native/fdlibm/dtoa.c             |    3 +-
 .../jni/gstreamer-peer/gst_native_pipeline.c       |    6 +-
 .../native/jni/java-lang/java_lang_VMProcess.c     |    3 +-
 libjava/gnu/classpath/natSystemProperties.cc       |    3 +-
 libjava/include/java-stack.h                       |    6 +-
 libstdc++-v3/libsupc++/del_opnt.cc                 |    3 +-
 lto-plugin/lto-plugin.c                            |    6 +-
 zlib/contrib/minizip/unzip.c                       |    2 +-
 zlib/contrib/minizip/zip.c                         |    2 +-
 zlib/examples/gun.c                                |    2 +-
 zlib/examples/gzappend.c                           |    2 +-
 zlib/examples/gzjoin.c                             |    3 +-
 zlib/gzio.c                                        |    2 +-
 74 files changed, 169 insertions(+), 292 deletions(-)

diff --git a/gcc/ada/initialize.c b/gcc/ada/initialize.c
index 32ea0e5..e2ad904 100644
--- a/gcc/ada/initialize.c
+++ b/gcc/ada/initialize.c
@@ -217,8 +217,7 @@  __gnat_initialize (void *eh ATTRIBUTE_UNUSED)

 		     FindClose (hDir);

-		     if (dir != NULL)
-		       free (dir);
+		     free (dir);
 		   }
 	       }
 	     else
diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c
index 85831eb..2f8887f1 100644
--- a/gcc/c-family/c-format.c
+++ b/gcc/c-family/c-format.c
@@ -1107,10 +1107,8 @@  init_dollar_format_checking (int first_arg_num, tree params)
     }
   if (dollar_arguments_alloc < dollar_arguments_count)
     {
-      if (dollar_arguments_used)
-	free (dollar_arguments_used);
-      if (dollar_arguments_pointer_p)
-	free (dollar_arguments_pointer_p);
+      free (dollar_arguments_used);
+      free (dollar_arguments_pointer_p);
       dollar_arguments_alloc = dollar_arguments_count;
       dollar_arguments_used = XNEWVEC (char, dollar_arguments_alloc);
       dollar_arguments_pointer_p = XNEWVEC (char, dollar_arguments_alloc);
diff --git a/gcc/calls.c b/gcc/calls.c
index f539f66..de953d0 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -2549,8 +2549,7 @@  expand_call (tree exp, rtx target, int ignore)
 		  highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
 						     needed);
 #endif
-		  if (stack_usage_map_buf)
-		    free (stack_usage_map_buf);
+		  free (stack_usage_map_buf);
 		  stack_usage_map_buf = XNEWVEC (char, highest_outgoing_arg_in_use);
 		  stack_usage_map = stack_usage_map_buf;

@@ -2655,8 +2654,7 @@  expand_call (tree exp, rtx target, int ignore)
 		    = stack_arg_under_construction;
 		  stack_arg_under_construction = 0;
 		  /* Make a new map for the new argument list.  */
-		  if (stack_usage_map_buf)
-		    free (stack_usage_map_buf);
+		  free (stack_usage_map_buf);
 		  stack_usage_map_buf = XCNEWVEC (char, highest_outgoing_arg_in_use);
 		  stack_usage_map = stack_usage_map_buf;
 		  highest_outgoing_arg_in_use = 0;
@@ -3148,8 +3146,7 @@  expand_call (tree exp, rtx target, int ignore)

       /* Free up storage we no longer need.  */
       for (i = 0; i < num_actuals; ++i)
-	if (args[i].aligned_regs)
-	  free (args[i].aligned_regs);
+	free (args[i].aligned_regs);

       insns = get_insns ();
       end_sequence ();
@@ -3204,8 +3201,7 @@  expand_call (tree exp, rtx target, int ignore)

   currently_expanding_call--;

-  if (stack_usage_map_buf)
-    free (stack_usage_map_buf);
+  free (stack_usage_map_buf);

   return target;
 }
@@ -3966,8 +3962,7 @@  emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
       stack_usage_map = initial_stack_usage_map;
     }

-  if (stack_usage_map_buf)
-    free (stack_usage_map_buf);
+  free (stack_usage_map_buf);

   return value;

diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index aaa0ea5..dda4d52 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -650,8 +650,7 @@  try_forward_edges (int mode, basic_block b)
       ei_next (&ei);
     }

-  if (threaded_edges)
-    free (threaded_edges);
+  free (threaded_edges);
   return changed;
 }
 
diff --git a/gcc/collect2.c b/gcc/collect2.c
index 42e35b6..9eac3cb 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -2092,8 +2092,7 @@  collect_execute (const char *prog, char **argv, const char *outname,
 	fatal (errmsg);
     }

-  if (response_arg)
-    free (response_arg);
+  free (response_arg);

   return pex;
 }
diff --git a/gcc/config/i386/gmm_malloc.h b/gcc/config/i386/gmm_malloc.h
index 7a7e840..8993fc7 100644
--- a/gcc/config/i386/gmm_malloc.h
+++ b/gcc/config/i386/gmm_malloc.h
@@ -67,8 +67,7 @@  _mm_malloc (size_t size, size_t align)
 static __inline__ void
 _mm_free (void * aligned_ptr)
 {
-  if (aligned_ptr)
-    free (((void **) aligned_ptr) [-1]);
+  free (((void **) aligned_ptr) [-1]);
 }

 #endif /* _MM_MALLOC_H_INCLUDED */
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 82d999b..936c3cf 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -4765,8 +4765,7 @@  ix86_valid_target_attribute_tree (tree args)

       /* Free up memory allocated to hold the strings */
       for (i = 0; i < IX86_FUNCTION_SPECIFIC_MAX; i++)
-	if (option_strings[i])
-	  free (option_strings[i]);
+	free (option_strings[i]);
     }

   return t;
diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c
index 8118276..f527452 100644
--- a/gcc/config/mcore/mcore.c
+++ b/gcc/config/mcore/mcore.c
@@ -1978,8 +1978,7 @@  mcore_expand_prolog (void)

       gcc_assert (GET_CODE (x) == SYMBOL_REF);

-      if (mcore_current_function_name)
-	free (mcore_current_function_name);
+      free (mcore_current_function_name);

       mcore_current_function_name = xstrdup (XSTR (x, 0));

diff --git a/gcc/coverage.c b/gcc/coverage.c
index 5da5464..b4da548 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -521,8 +521,7 @@  coverage_checksum_string (unsigned chksum, const char *string)
     }

   chksum = crc32_string (chksum, string);
-  if (dup)
-    free (dup);
+  free (dup);

   return chksum;
 }
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 56639ff..91e7078 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1506,8 +1506,7 @@  cxx_printable_name_internal (tree decl, int v, bool translate)
       gcc_assert (uid_ring[ring_counter] != DECL_UID (current_function_decl));
     }

-  if (print_ring[ring_counter])
-    free (print_ring[ring_counter]);
+  free (print_ring[ring_counter]);

   print_ring[ring_counter] = xstrdup (lang_decl_name (decl, v, translate));
   uid_ring[ring_counter] = DECL_UID (decl);
diff --git a/gcc/cse.c b/gcc/cse.c
index f7b477c..d83b38a 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -796,8 +796,7 @@  init_cse_reg_info (unsigned int nregs)
 	}

       /* Reallocate the table with NEW_SIZE entries.  */
-      if (cse_reg_info_table)
-	free (cse_reg_info_table);
+      free (cse_reg_info_table);
       cse_reg_info_table = XNEWVEC (struct cse_reg_info, new_size);
       cse_reg_info_table_size = new_size;
       cse_reg_info_table_first_uninitialized = 0;
@@ -6975,8 +6974,7 @@  delete_trivially_dead_insns (rtx insns, int nreg)
 		df_insn_rescan (insn);
 	      }
 	  }
-      if (replacements)
-	free (replacements);
+      free (replacements);
     }

   if (dump_file && ndead)
diff --git a/gcc/cselib.c b/gcc/cselib.c
index c142d67..ce8564b 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -2429,8 +2429,7 @@  cselib_init (int record_what)
   if (!reg_values || reg_values_size < cselib_nregs
       || (reg_values_size > 10 && reg_values_size > cselib_nregs * 4))
     {
-      if (reg_values)
-	free (reg_values);
+      free (reg_values);
       /* Some space for newly emit instructions so we don't end up
 	 reallocating in between passes.  */
       reg_values_size = cselib_nregs + (63 + cselib_nregs) / 16;
diff --git a/gcc/df-core.c b/gcc/df-core.c
index 36270bf..2860521 100644
--- a/gcc/df-core.c
+++ b/gcc/df-core.c
@@ -811,10 +811,8 @@  rest_of_handle_df_finish (void)
       dflow->problem->free_fun ();
     }

-  if (df->postorder)
-    free (df->postorder);
-  if (df->postorder_inverted)
-    free (df->postorder_inverted);
+  free (df->postorder);
+  free (df->postorder_inverted);
   free (df->hard_regs_live_count);
   free (df);
   df = NULL;
@@ -1183,10 +1181,8 @@  df_analyze (void)
   bool everything;
   int i;

-  if (df->postorder)
-    free (df->postorder);
-  if (df->postorder_inverted)
-    free (df->postorder_inverted);
+  free (df->postorder);
+  free (df->postorder_inverted);
   df->postorder = XNEWVEC (int, last_basic_block);
   df->postorder_inverted = XNEWVEC (int, last_basic_block);
   df->n_blocks = post_order_compute (df->postorder, true, true);
@@ -1726,8 +1722,7 @@  df_check_cfg_clean (void)
 static void
 df_set_clean_cfg (void)
 {
-  if (saved_cfg)
-    free (saved_cfg);
+  free (saved_cfg);
   saved_cfg = df_compute_cfg_image ();
 }

diff --git a/gcc/fortran/gfortranspec.c b/gcc/fortran/gfortranspec.c
index 2d732fd..477e4a0 100644
--- a/gcc/fortran/gfortranspec.c
+++ b/gcc/fortran/gfortranspec.c
@@ -472,8 +472,7 @@  For more information about these matters, see the file named COPYING\n\n"));
 int
 lang_specific_pre_link (void)
 {
-  if (spec_file)
-    free (spec_file);
+  free (spec_file);
   else if (library)
     do_spec ("%:include(libgfortran.spec)");

diff --git a/gcc/function.c b/gcc/function.c
index 19b480d..d5efa4a 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -211,8 +211,7 @@  free_after_compilation (struct function *f)
   prologue_insn_hash = NULL;
   epilogue_insn_hash = NULL;

-  if (crtl->emit.regno_pointer_align)
-    free (crtl->emit.regno_pointer_align);
+  free (crtl->emit.regno_pointer_align);

   memset (crtl, 0, sizeof (struct rtl_data));
   f->eh = NULL;
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 75f522e..6906089 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -4782,8 +4782,7 @@  do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
 		    t->filename_length = temp_filename_length;
 		  }

-		if (saved_suffix)
-		  free (saved_suffix);
+		free (saved_suffix);

 		obstack_grow (&obstack, t->filename, t->filename_length);
 		delete_this_arg = 1;
@@ -6700,12 +6699,10 @@  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
 	    {
 	      if (compare_debug)
 		{
-		  if (debug_check_temp_file[0])
-		    free (debug_check_temp_file[0]);
+		  free (debug_check_temp_file[0]);
 		  debug_check_temp_file[0] = NULL;

-		  if (debug_check_temp_file[1])
-		    free (debug_check_temp_file[1]);
+		  free (debug_check_temp_file[1]);
 		  debug_check_temp_file[1] = NULL;
 		}

@@ -6749,12 +6746,10 @@  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"

 	      if (compare_debug)
 		{
-		  if (debug_check_temp_file[0])
-		    free (debug_check_temp_file[0]);
+		  free (debug_check_temp_file[0]);
 		  debug_check_temp_file[0] = NULL;

-		  if (debug_check_temp_file[1])
-		    free (debug_check_temp_file[1]);
+		  free (debug_check_temp_file[1]);
 		  debug_check_temp_file[1] = NULL;
 		}
 	    }
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 2fbeaf5..dd71224 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -661,10 +661,8 @@  create_file_names (const char *file_name)
   int base;

   /* Free previous file names.  */
-  if (bbg_file_name)
-    free (bbg_file_name);
-  if (da_file_name)
-    free (da_file_name);
+  free (bbg_file_name);
+  free (da_file_name);
   da_file_name = bbg_file_name = NULL;
   bbg_file_time = 0;
   bbg_stamp = 0;
diff --git a/gcc/gensupport.c b/gcc/gensupport.c
index e81682c..1c308c7 100644
--- a/gcc/gensupport.c
+++ b/gcc/gensupport.c
@@ -350,8 +350,7 @@  identify_predicable_attribute (void)
   if (p_true == NULL || strchr (++p_true, ',') != NULL)
     {
       error_with_line (elem->lineno, "attribute `predicable' is not a boolean");
-      if (p_false)
-        free (p_false);
+      free (p_false);
       return;
     }
   p_true[-1] = '\0';
@@ -367,15 +366,13 @@  identify_predicable_attribute (void)

     case CONST:
       error_with_line (elem->lineno, "attribute `predicable' cannot be const");
-      if (p_false)
-	free (p_false);
+      free (p_false);
       return;

     default:
       error_with_line (elem->lineno,
 		       "attribute `predicable' must have a constant default");
-      if (p_false)
-	free (p_false);
+      free (p_false);
       return;
     }

@@ -387,8 +384,7 @@  identify_predicable_attribute (void)
     {
       error_with_line (elem->lineno,
 		       "unknown value `%s' for `predicable' attribute", value);
-      if (p_false)
-	free (p_false);
+      free (p_false);
     }
 }

diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 47a03d5..83c0d6d 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -114,8 +114,7 @@  save_clast_name_index (htab_t index_table, const char *name, int index)

   if (slot)
     {
-      if (*slot)
-	free (*slot);
+      free (*slot);

       *slot = new_clast_name_index (name, index);
     }
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 064ded3..7474be0 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -190,8 +190,7 @@  free_data_refs_aux (VEC (data_reference_p, heap) *datarefs)
       {
 	base_alias_pair *bap = (base_alias_pair *)(dr->aux);

-	if (bap->alias_set)
-	  free (bap->alias_set);
+	free (bap->alias_set);

 	free (bap);
 	dr->aux = NULL;
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index e16561f..67cef40 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -5556,8 +5556,7 @@  haifa_finish_h_i_d (void)

   FOR_EACH_VEC_ELT (haifa_insn_data_def, h_i_d, i, data)
     {
-      if (data->reg_pressure != NULL)
-	free (data->reg_pressure);
+      free (data->reg_pressure);
       for (use = data->reg_use_list; use != NULL; use = next)
 	{
 	  next = use->next_insn_use;
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 82599f1..58f3303d 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -1893,8 +1893,7 @@  ipa_free_all_edge_args (void)
 void
 ipa_free_node_params_substructures (struct ipa_node_params *info)
 {
-  if (info->params)
-    free (info->params);
+  free (info->params);

   memset (info, 0, sizeof (*info));
 }
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 3b4cc02..6a8b391 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -1667,8 +1667,7 @@  local_pure_const (void)
 		 lang_hooks.decl_printable_name (current_function_decl,
 						 2));
     }
-  if (l)
-    free (l);
+  free (l);
   if (changed)
     return execute_fixup_cfg ();
   else
diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
index f874a2e..40fa6bc 100644
--- a/gcc/ipa-reference.c
+++ b/gcc/ipa-reference.c
@@ -913,8 +913,7 @@  propagate (void)
 				  node_g->statics_written);
 	    }
 	}
-      if (node_info)
-	free (node_info);
+      free (node_info);
       if (node->aux)
 	{
 	  free (node->aux);
diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c
index 2329613..2afddca 100644
--- a/gcc/ira-costs.c
+++ b/gcc/ira-costs.c
@@ -1619,22 +1619,17 @@  free_ira_costs (void)
 {
   int i;

-  if (init_cost != NULL)
-    free (init_cost);
+  free (init_cost);
   init_cost = NULL;
   for (i = 0; i < MAX_RECOG_OPERANDS; i++)
     {
-      if (op_costs[i] != NULL)
-	free (op_costs[i]);
-      if (this_op_costs[i] != NULL)
-	free (this_op_costs[i]);
+      free (op_costs[i]);
+      free (this_op_costs[i]);
       op_costs[i] = this_op_costs[i] = NULL;
     }
-  if (temp_costs != NULL)
-    free (temp_costs);
+  free (temp_costs);
   temp_costs = NULL;
-  if (cost_classes != NULL)
-    free (cost_classes);
+  free (cost_classes);
   cost_classes = NULL;
 }

diff --git a/gcc/ira.c b/gcc/ira.c
index 68d47fb..b8a72a3 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -1150,10 +1150,8 @@  free_register_move_costs (void)

   for (mode = 0; mode < MAX_MACHINE_MODE; mode++)
     {
-      if (ira_may_move_in_cost[mode] != NULL)
-	free (ira_may_move_in_cost[mode]);
-      if (ira_may_move_out_cost[mode] != NULL)
-	free (ira_may_move_out_cost[mode]);
+      free (ira_may_move_in_cost[mode]);
+      free (ira_may_move_out_cost[mode]);
       ira_register_move_cost[mode] = NULL;
       ira_may_move_in_cost[mode] = NULL;
       ira_may_move_out_cost[mode] = NULL;
@@ -3036,8 +3034,7 @@  build_insn_chain (void)
     }

   for (i = 0; i < (unsigned int) max_regno; i++)
-    if (live_subregs[i])
-      free (live_subregs[i]);
+    free (live_subregs[i]);

   reload_insn_chain = c;
   *p = NULL;
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index d10791f..2a1d522 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -1843,8 +1843,7 @@  java_parse_file (void)
       list = next;
     }

-  if (file_list != NULL)
-    free (file_list);
+  free (file_list);

   if (filename_count == 0)
     warning (0, "no input file specified");
diff --git a/gcc/matrix-reorg.c b/gcc/matrix-reorg.c
index c303143..8ea6e84 100644
--- a/gcc/matrix-reorg.c
+++ b/gcc/matrix-reorg.c
@@ -529,12 +529,9 @@  mat_free (void *e)
   if (!mat)
     return;

-  if (mat->free_stmts)
-    free (mat->free_stmts);
-  if (mat->dim_hot_level)
-    free (mat->dim_hot_level);
-  if (mat->malloc_for_level)
-    free (mat->malloc_for_level);
+  free (mat->free_stmts);
+  free (mat->dim_hot_level);
+  free (mat->malloc_for_level);
 }

 /* Find all potential matrices.
diff --git a/gcc/prefix.c b/gcc/prefix.c
index c72203c..0167f9c 100644
--- a/gcc/prefix.c
+++ b/gcc/prefix.c
@@ -103,8 +103,7 @@  get_key_value (char *key)
   if (prefix == 0)
     prefix = std_prefix;

-  if (temp)
-    free (temp);
+  free (temp);

   return prefix;
 }
diff --git a/gcc/profile.c b/gcc/profile.c
index 2334101..ed264bc 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -828,8 +828,7 @@  compute_value_histograms (histogram_values values)
     }

   for (t = 0; t < GCOV_N_VALUE_COUNTERS; t++)
-    if (histogram_counts[t])
-      free (histogram_counts[t]);
+    free (histogram_counts[t]);
 }

 /* The entry basic block will be moved around so that it has index=1,
diff --git a/gcc/reload1.c b/gcc/reload1.c
index 3d58e58..d07febd 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -4206,19 +4206,15 @@  free_reg_equiv (void)
 {
   int i;

-  if (reg_equiv_constant)
-    free (reg_equiv_constant);
-  if (reg_equiv_invariant)
-    free (reg_equiv_invariant);
+  free (reg_equiv_constant);
+  free (reg_equiv_invariant);
   reg_equiv_constant = 0;
   reg_equiv_invariant = 0;
   VEC_free (rtx, gc, reg_equiv_memory_loc_vec);
   reg_equiv_memory_loc = 0;

-  if (offsets_known_at)
-    free (offsets_known_at);
-  if (offsets_at)
-    free (offsets_at);
+  free (offsets_known_at);
+  free (offsets_at);
   offsets_at = 0;
   offsets_known_at = 0;

diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 7293fc3..240e0e3 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -3550,8 +3550,7 @@  free_deps (struct deps_desc *deps)

   /* As we initialize reg_last lazily, it is possible that we didn't allocate
      it at all.  */
-  if (deps->reg_last)
-    free (deps->reg_last);
+  free (deps->reg_last);
   deps->reg_last = NULL;

   deps = NULL;
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index b88dad1..fc31d19 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -580,8 +580,7 @@  fence_clear (fence_t f)
   gcc_assert ((s != NULL && dc != NULL && tc != NULL)
 	      || (s == NULL && dc == NULL && tc == NULL));

-  if (s != NULL)
-    free (s);
+  free (s);

   if (dc != NULL)
     delete_deps_context (dc);
diff --git a/gcc/sese.c b/gcc/sese.c
index bfb0276..3ce83b9 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -449,8 +449,7 @@  set_rename (htab_t rename_map, tree old_name, tree expr)
   if (!slot)
     return;

-  if (*slot)
-    free (*slot);
+  free (*slot);

   *slot = new_rename_map_elt (old_name, expr);
 }
@@ -676,8 +675,7 @@  if_region_set_false_region (ifsese if_region, sese region)

   SESE_EXIT (region) = false_edge;

-  if (if_region->false_region)
-    free (if_region->false_region);
+  free (if_region->false_region);
   if_region->false_region = region;

   if (slot)
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 54cb46c..ef7c414 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -5085,11 +5085,9 @@  free_rdg (struct graph *rdg)
       struct graph_edge *e;

       for (e = v->succ; e; e = e->succ_next)
-	if (e->data)
-	  free (e->data);
+	free (e->data);

-      if (v->data)
-	free (v->data);
+      free (v->data);
     }

   htab_delete (rdg->indices);
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index f189b9b..948a796 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -1617,8 +1617,7 @@  lower_try_finally (struct leh_state *state, gimple tp)
     }

   VEC_free (tree, heap, this_tf.dest_array);
-  if (this_tf.goto_queue)
-    free (this_tf.goto_queue);
+  free (this_tf.goto_queue);
   if (this_tf.goto_queue_map)
     pointer_map_destroy (this_tf.goto_queue_map);

diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
index e7490e6..2dfe37e 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -242,8 +242,7 @@  delete_coalesce_list (coalesce_list_p cl)
 {
   gcc_assert (cl->cost_one_list == NULL);
   htab_delete (cl->list);
-  if (cl->sorted)
-    free (cl->sorted);
+  free (cl->sorted);
   gcc_assert (cl->num_sorted == 0);
   free (cl);
 }
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 0441df6..4a8a4eb 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -157,10 +157,8 @@  delete_var_map (var_map map)
 {
   var_map_base_fini (map);
   partition_delete (map->var_partition);
-  if (map->partition_to_view)
-    free (map->partition_to_view);
-  if (map->view_to_partition)
-    free (map->view_to_partition);
+  free (map->partition_to_view);
+  free (map->view_to_partition);
   free (map);
 }

diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 479b46f..723812f 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -6254,8 +6254,7 @@  free_loop_data (struct ivopts_data *data)
       struct version_info *info;

       info = ver_info (data, i);
-      if (info->iv)
-	free (info->iv);
+      free (info->iv);
       info->iv = NULL;
       info->has_nonlin_use = false;
       info->preserve_biv = false;
@@ -6282,8 +6281,7 @@  free_loop_data (struct ivopts_data *data)
     {
       struct iv_cand *cand = iv_cand (data, i);

-      if (cand->iv)
-	free (cand->iv);
+      free (cand->iv);
       if (cand->depends_on)
 	BITMAP_FREE (cand->depends_on);
       free (cand);
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index f246643..f13adaf 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -580,8 +580,7 @@  phi_trans_add (pre_expr e, pre_expr v, basic_block pred)

   slot = htab_find_slot_with_hash (phi_translate_table, new_pair,
 				   new_pair->hashcode, INSERT);
-  if (*slot)
-    free (*slot);
+  free (*slot);
   *slot = (void *) new_pair;
 }

diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c
index 6faac57..ba3cc9a 100644
--- a/intl/bindtextdom.c
+++ b/intl/bindtextdom.c
@@ -204,8 +204,7 @@  set_binding_values (domainname, dirnamep, codesetp)

 		  if (__builtin_expect (result != NULL, 1))
 		    {
-		      if (binding->codeset != NULL)
-			free (binding->codeset);
+		      free (binding->codeset);

 		      binding->codeset = result;
 		      binding->codeset_cntr++;
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index 536ee12..e6cff98 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -1273,8 +1273,7 @@  _nl_load_domain (domain_file, domainbinding)
       /* This is an invalid revision.  */
     invalid:
       /* This is an invalid .mo file.  */
-      if (domain->malloced)
-	free (domain->malloced);
+      free (domain->malloced);
 #ifdef HAVE_MMAP
       if (use_mmap)
 	munmap ((caddr_t) data, size);
@@ -1307,8 +1306,7 @@  _nl_unload_domain (domain)

   _nl_free_domain_conv (domain);

-  if (domain->malloced)
-    free (domain->malloced);
+  free (domain->malloced);

 # ifdef _POSIX_MAPPED_FILES
   if (domain->use_mmap)
diff --git a/intl/localcharset.c b/intl/localcharset.c
index 8ece6e3..4df9fee 100644
--- a/intl/localcharset.c
+++ b/intl/localcharset.c
@@ -199,8 +199,7 @@  get_charset_aliases ()
 	    }
 	}

-      if (file_name != NULL)
-	free (file_name);
+      free (file_name);

 #else

diff --git a/libcpp/files.c b/libcpp/files.c
index 456c0b0..f464fea 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -996,8 +996,7 @@  make_cpp_file (cpp_reader *pfile, cpp_dir *dir, const char *fname)
 static void
 destroy_cpp_file (_cpp_file *file)
 {
-  if (file->buffer_start)
-    free ((void *) file->buffer_start);
+  free ((void *) file->buffer_start);
   free ((void *) file->name);
   free (file);
 }
diff --git a/libcpp/init.c b/libcpp/init.c
index cfc16e8..ae1c0b8 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -258,8 +258,7 @@  cpp_destroy (cpp_reader *pfile)
   while (CPP_BUFFER (pfile) != NULL)
     _cpp_pop_buffer (pfile);

-  if (pfile->out.base)
-    free (pfile->out.base);
+  free (pfile->out.base);

   if (pfile->macro_buffer)
     {
diff --git a/libcpp/macro.c b/libcpp/macro.c
index d9324a3..eba2349 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -1064,8 +1064,7 @@  replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro, macro_arg

   /* Free the expanded arguments.  */
   for (i = 0; i < macro->paramc; i++)
-    if (args[i].expanded)
-      free (args[i].expanded);
+    free (args[i].expanded);

   push_ptoken_context (pfile, node, buff, first, dest - first);
 }
diff --git a/libcpp/pch.c b/libcpp/pch.c
index 00b7794..d278f14 100644
--- a/libcpp/pch.c
+++ b/libcpp/pch.c
@@ -713,12 +713,9 @@  cpp_valid_state (cpp_reader *r, const char *name, int fd)
   return -1;

  fail:
-  if (namebuf != NULL)
-    free (namebuf);
-  if (undeftab != NULL)
-    free (undeftab);
-  if (nl.defs != NULL)
-    free (nl.defs);
+  free (namebuf);
+  free (undeftab);
+  free (nl.defs);
   return 1;
 }

diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c
index d097cab..cf2d32e 100644
--- a/libdecnumber/decNumber.c
+++ b/libdecnumber/decNumber.c
@@ -711,7 +711,7 @@  decNumber * decNumberFromString(decNumber *dn, const char chars[],
     /* decNumberShow(dn); */
     } while(0); 			/* [for break] */

-  if (allocres!=NULL) free(allocres);	/* drop any storage used */
+  free(allocres);	/* drop any storage used */
   if (status!=0) decStatus(dn, status, set);
   return dn;
   } /* decNumberFromString */
@@ -970,8 +970,8 @@  decNumber * decNumberCompareTotalMag(decNumber *res, const decNumber *lhs,
     decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status);
     } while(0); 			/* end protected */

-  if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
-  if (allocbufb!=NULL) free(allocbufb); /* .. */
+  free(allocbufa); /* drop any storage used */
+  free(allocbufb); /* .. */
   if (status!=0) decStatus(res, status, set);
   return res;
   } /* decNumberCompareTotalMag */
@@ -1074,7 +1074,7 @@  decNumber * decNumberExp(decNumber *res, const decNumber *rhs,
     } while(0); 			/* end protected */

   #if DECSUBSET
-  if (allocrhs !=NULL) free(allocrhs);	/* drop any storage used */
+  free(allocrhs);	/* drop any storage used */
   #endif
   /* apply significant status */
   if (status!=0) decStatus(res, status, set);
@@ -1169,7 +1169,7 @@  decNumber * decNumberFMA(decNumber *res, const decNumber *lhs,
     decAddOp(res, acc, fhs, set, 0, &status);
     } while(0); 			/* end protected */

-  if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
+  free(allocbufa); /* drop any storage used */
   if (status!=0) decStatus(res, status, set);
   #if DECCHECK
   decCheckInexact(res, set);
@@ -1296,7 +1296,7 @@  decNumber * decNumberLn(decNumber *res, const decNumber *rhs,
     } while(0); 			/* end protected */

   #if DECSUBSET
-  if (allocrhs !=NULL) free(allocrhs);	/* drop any storage used */
+  free(allocrhs);	/* drop any storage used */
   #endif
   /* apply significant status */
   if (status!=0) decStatus(res, status, set);
@@ -1509,10 +1509,10 @@  decNumber * decNumberLog10(decNumber *res, const decNumber *rhs,
     decDivideOp(res, a, b, &aset, DIVIDE, &status); /* into result */
     } while(0); 			/* [for break] */

-  if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
-  if (allocbufb!=NULL) free(allocbufb); /* .. */
+  free(allocbufa); /* drop any storage used */
+  free(allocbufb); /* .. */
   #if DECSUBSET
-  if (allocrhs !=NULL) free(allocrhs);	/* .. */
+  free(allocrhs);	/* .. */
   #endif
   /* apply significant status */
   if (status!=0) decStatus(res, status, set);
@@ -2253,11 +2253,11 @@  decNumber * decNumberPower(decNumber *res, const decNumber *lhs,
     #endif
     } while(0); 			/* end protected */

-  if (allocdac!=NULL) free(allocdac);	/* drop any storage used */
-  if (allocinv!=NULL) free(allocinv);	/* .. */
+  free(allocdac);	/* drop any storage used */
+  free(allocinv);	/* .. */
   #if DECSUBSET
-  if (alloclhs!=NULL) free(alloclhs);	/* .. */
-  if (allocrhs!=NULL) free(allocrhs);	/* .. */
+  free(alloclhs);	/* .. */
+  free(allocrhs);	/* .. */
   #endif
   if (status!=0) decStatus(res, status, set);
   #if DECCHECK
@@ -2349,7 +2349,7 @@  decNumber * decNumberReduce(decNumber *res, const decNumber *rhs,
     } while(0); 			     /* end protected */

   #if DECSUBSET
-  if (allocrhs !=NULL) free(allocrhs);	     /* .. */
+  free(allocrhs);	     /* .. */
   #endif
   if (status!=0) decStatus(res, status, set);/* then report status */
   return res;
@@ -3111,11 +3111,11 @@  decNumber * decNumberSquareRoot(decNumber *res, const decNumber *rhs,
     decNumberCopy(res, a);		     /* a is now the result */
     } while(0); 			     /* end protected */

-  if (allocbuff!=NULL) free(allocbuff);      /* drop any storage used */
-  if (allocbufa!=NULL) free(allocbufa);      /* .. */
-  if (allocbufb!=NULL) free(allocbufb);      /* .. */
+  free(allocbuff);      /* drop any storage used */
+  free(allocbufa);      /* .. */
+  free(allocbufb);      /* .. */
   #if DECSUBSET
-  if (allocrhs !=NULL) free(allocrhs);	     /* .. */
+  free(allocrhs);	     /* .. */
   #endif
   if (status!=0) decStatus(res, status, set);/* then report status */
   #if DECCHECK
@@ -4130,10 +4130,10 @@  static decNumber * decAddOp(decNumber *res, const decNumber *lhs,
       }
     } while(0); 			     /* end protected */

-  if (allocacc!=NULL) free(allocacc);	     /* drop any storage used */
+  free(allocacc);	     /* drop any storage used */
   #if DECSUBSET
-  if (allocrhs!=NULL) free(allocrhs);	     /* .. */
-  if (alloclhs!=NULL) free(alloclhs);	     /* .. */
+  free(allocrhs);	     /* .. */
+  free(alloclhs);	     /* .. */
   #endif
   return res;
   } /* decAddOp */
@@ -4782,11 +4782,11 @@  static decNumber * decDivideOp(decNumber *res,
     #endif
     } while(0); 			     /* end protected */

-  if (varalloc!=NULL) free(varalloc);	/* drop any storage used */
-  if (allocacc!=NULL) free(allocacc);	/* .. */
+  free(varalloc);	/* drop any storage used */
+  free(allocacc);	/* .. */
   #if DECSUBSET
-  if (allocrhs!=NULL) free(allocrhs);	/* .. */
-  if (alloclhs!=NULL) free(alloclhs);	/* .. */
+  free(allocrhs);	/* .. */
+  free(alloclhs);	/* .. */
   #endif
   return res;
   } /* decDivideOp */
@@ -5127,14 +5127,14 @@  static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
     decFinish(res, set, &residue, status);   /* final cleanup */
     } while(0); 			/* end protected */

-  if (allocacc!=NULL) free(allocacc);	/* drop any storage used */
+  free(allocacc);	/* drop any storage used */
   #if DECSUBSET
-  if (allocrhs!=NULL) free(allocrhs);	/* .. */
-  if (alloclhs!=NULL) free(alloclhs);	/* .. */
+  free(allocrhs);	/* .. */
+  free(alloclhs);	/* .. */
   #endif
   #if FASTMUL
-  if (allocrhi!=NULL) free(allocrhi);	/* .. */
-  if (alloclhi!=NULL) free(alloclhi);	/* .. */
+  free(allocrhi);	/* .. */
+  free(alloclhi);	/* .. */
   #endif
   return res;
   } /* decMultiplyOp */
@@ -5483,9 +5483,9 @@  decNumber * decExpOp(decNumber *res, const decNumber *rhs,
     decFinish(res, set, &residue, status);	 /* cleanup/set flags */
     } while(0); 			/* end protected */

-  if (allocrhs !=NULL) free(allocrhs);	/* drop any storage used */
-  if (allocbufa!=NULL) free(allocbufa); /* .. */
-  if (allocbuft!=NULL) free(allocbuft); /* .. */
+  free(allocrhs);	/* drop any storage used */
+  free(allocbufa); /* .. */
+  free(allocbuft); /* .. */
   /* [status is handled by caller] */
   return res;
   } /* decExpOp */
@@ -5794,8 +5794,8 @@  decNumber * decLnOp(decNumber *res, const decNumber *rhs,
     decFinish(res, set, &residue, status);	 /* cleanup/set flags */
     } while(0); 			/* end protected */

-  if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
-  if (allocbufb!=NULL) free(allocbufb); /* .. */
+  free(allocbufa); /* drop any storage used */
+  free(allocbufb); /* .. */
   /* [status is handled by caller] */
   return res;
   } /* decLnOp */
@@ -5959,8 +5959,8 @@  static decNumber * decQuantizeOp(decNumber *res, const decNumber *lhs,
     } while(0); 			/* end protected */

   #if DECSUBSET
-  if (allocrhs!=NULL) free(allocrhs);	/* drop any storage used */
-  if (alloclhs!=NULL) free(alloclhs);	/* .. */
+  free(allocrhs);	/* drop any storage used */
+  free(alloclhs);	/* .. */
   #endif
   return res;
   } /* decQuantizeOp */
@@ -6142,8 +6142,8 @@  decNumber * decCompareOp(decNumber *res, const decNumber *lhs,
       }
     }
   #if DECSUBSET
-  if (allocrhs!=NULL) free(allocrhs);	/* free any storage used */
-  if (alloclhs!=NULL) free(alloclhs);	/* .. */
+  free(allocrhs);	/* free any storage used */
+  free(alloclhs);	/* .. */
   #endif
   return res;
   } /* decCompareOp */
@@ -6277,7 +6277,7 @@  static Int decUnitCompare(const Unit *a, Int alength,
     result=(*u==0 ? 0 : +1);
     }
   /* clean up and return the result */
-  if (allocacc!=NULL) free(allocacc);	/* drop any storage used */
+  free(allocacc);	/* drop any storage used */
   return result;
   } /* decUnitCompare */

diff --git a/libgfortran/intrinsics/move_alloc.c b/libgfortran/intrinsics/move_alloc.c
index 9b5497c..f76c20c 100644
--- a/libgfortran/intrinsics/move_alloc.c
+++ b/libgfortran/intrinsics/move_alloc.c
@@ -37,8 +37,7 @@  move_alloc (gfc_array_char * from, gfc_array_char * to)
 {
   int i;

-  if (to->data)
-    free (to->data);
+  free (to->data);

   for (i = 0; i < GFC_DESCRIPTOR_RANK (from); i++)
     {
diff --git a/libgfortran/io/fbuf.c b/libgfortran/io/fbuf.c
index 82b3f6b..353e5ae 100644
--- a/libgfortran/io/fbuf.c
+++ b/libgfortran/io/fbuf.c
@@ -51,8 +51,7 @@  fbuf_destroy (gfc_unit * u)
 {
   if (u->fbuf == NULL)
     return;
-  if (u->fbuf->buf)
-    free (u->fbuf->buf);
+  free (u->fbuf->buf);
   free (u->fbuf);
   u->fbuf = NULL;
 }
diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c
index d540fc4..70f4f2d 100644
--- a/libgfortran/io/format.c
+++ b/libgfortran/io/format.c
@@ -149,8 +149,7 @@  save_parsed_format (st_parameter_dt *dtp)
     free_format_data (u->format_hash_table[hash].hashed_fmt);
   u->format_hash_table[hash].hashed_fmt = NULL;

-  if (u->format_hash_table[hash].key != NULL)
-    free (u->format_hash_table[hash].key);
+  free (u->format_hash_table[hash].key);
   u->format_hash_table[hash].key = get_mem (dtp->format_len);
   memcpy (u->format_hash_table[hash].key, dtp->format, dtp->format_len);

diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index d7448c0..f0abeeb 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -689,8 +689,7 @@  already_open (st_parameter_open *opp, gfc_unit * u, unit_flags * flags)
 	}

       u->s = NULL;
-      if (u->file)
-	free (u->file);
+      free (u->file);
       u->file = NULL;
       u->file_len = 0;

diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c
index 1d52217..e8a9b84 100644
--- a/libgfortran/io/unit.c
+++ b/libgfortran/io/unit.c
@@ -483,11 +483,9 @@  free_internal_unit (st_parameter_dt *dtp)

   if (dtp->u.p.current_unit != NULL)
     {
-      if (dtp->u.p.current_unit->ls != NULL)
-	free (dtp->u.p.current_unit->ls);
+      free (dtp->u.p.current_unit->ls);

-      if (dtp->u.p.current_unit->s)
-	free (dtp->u.p.current_unit->s);
+      free (dtp->u.p.current_unit->s);

       destroy_unit_mutex (dtp->u.p.current_unit);
     }
@@ -652,8 +650,7 @@  close_unit_1 (gfc_unit *u, int locked)

   delete_unit (u);

-  if (u->file)
-    free (u->file);
+  free (u->file);
   u->file = NULL;
   u->file_len = 0;

diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 12536ca..fd16fbe 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -849,8 +849,7 @@  mem_flush (unix_stream * s __attribute__ ((unused)))
 static int
 mem_close (unix_stream * s)
 {
-  if (s != NULL)
-    free (s);
+  free (s);

   return 0;
 }
diff --git a/libgo/runtime/go-select.c b/libgo/runtime/go-select.c
index 9d9f728..8f35a10 100644
--- a/libgo/runtime/go-select.c
+++ b/libgo/runtime/go-select.c
@@ -690,8 +690,7 @@  __go_select (size_t count, _Bool has_default,
 	      continue;
 	    }

-	  if (allocated_buffer != NULL)
-	    free (allocated_buffer);
+	  free (allocated_buffer);

 	  return ret;
 	}
@@ -703,8 +702,7 @@  __go_select (size_t count, _Bool has_default,
       if (has_default)
 	{
 	  /* Use the default clause.  */
-	  if (allocated_buffer != NULL)
-	    free (allocated_buffer);
+	  free (allocated_buffer);
 	  return 0;
 	}

diff --git a/libiberty/cp-demint.c b/libiberty/cp-demint.c
index 2e8f8d2..1d1a77a 100644
--- a/libiberty/cp-demint.c
+++ b/libiberty/cp-demint.c
@@ -206,10 +206,8 @@  cplus_demangle_v3_components (const char *mangled, int options, void **mem)
 	     malloc (di.num_subs * sizeof (struct demangle_component *)));
   if (di.comps == NULL || di.subs == NULL)
     {
-      if (di.comps != NULL)
-	free (di.comps);
-      if (di.subs != NULL)
-	free (di.subs);
+      free (di.comps);
+      free (di.subs);
       return NULL;
     }

diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c
index 84f94b6..e948487 100644
--- a/libiberty/cplus-dem.c
+++ b/libiberty/cplus-dem.c
@@ -1311,8 +1311,7 @@  delete_non_B_K_work_stuff (struct work_stuff *work)
       int i;

       for (i = 0; i < work->ntmpl_args; i++)
-	if (work->tmpl_argvec[i])
-	  free ((char*) work->tmpl_argvec[i]);
+	free ((char*) work->tmpl_argvec[i]);

       free ((char*) work->tmpl_argvec);
       work->tmpl_argvec = NULL;
diff --git a/libiberty/pex-common.c b/libiberty/pex-common.c
index 55b63ae..6fd3fde 100644
--- a/libiberty/pex-common.c
+++ b/libiberty/pex-common.c
@@ -623,12 +623,9 @@  pex_free (struct pex_obj *obj)

   if (obj->next_input_name_allocated)
     free (obj->next_input_name);
-  if (obj->children != NULL)
-    free (obj->children);
-  if (obj->status != NULL)
-    free (obj->status);
-  if (obj->time != NULL)
-    free (obj->time);
+  free (obj->children);
+  free (obj->status);
+  free (obj->time);

   if (obj->remove_count > 0)
     {
diff --git a/libiberty/pex-msdos.c b/libiberty/pex-msdos.c
index 4b77bf6..fa0f40a 100644
--- a/libiberty/pex-msdos.c
+++ b/libiberty/pex-msdos.c
@@ -310,10 +310,8 @@  pex_msdos_cleanup (struct pex_obj  *obj)

   ms = (struct pex_msdos *) obj->sysdep;
   for (i = 0; i < PEX_MSDOS_FILE_COUNT; ++i)
-    if (msdos->files[i] != NULL)
-      free (msdos->files[i]);
-  if (msdos->statuses != NULL)
-    free (msdos->statuses);
+    free (msdos->files[i]);
+  free (msdos->statuses);
   free (msdos);
   obj->sysdep = NULL;
 }
diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c
index 4427406..107ac6f 100644
--- a/libiberty/pex-win32.c
+++ b/libiberty/pex-win32.c
@@ -210,10 +210,8 @@  mingw_rootify (const char *executable)
   if (!namebuf || !foundbuf)
     {
       RegCloseKey (hKey);
-      if (namebuf)
-	free (namebuf);
-      if (foundbuf)
-	free (foundbuf);
+      free (namebuf);
+      free (foundbuf);
       return executable;
     }

@@ -315,8 +313,7 @@  msys_rootify (const char *executable)
     return tack_on_executable (buf, executable);

   /* failed */
-  if (buf)
-    free (buf);
+  free (buf);
   return executable;
 }
 #endif
@@ -607,8 +604,7 @@  win32_spawn (const char *executable,
 		      si,
 		      pi))
     {
-      if (env_block)
-        free (env_block);
+      free (env_block);

       free (full_executable);

@@ -618,18 +614,14 @@  win32_spawn (const char *executable,
   /* Clean up.  */
   CloseHandle (pi->hThread);
   free (full_executable);
-  if (env_block)
-    free (env_block);
+  free (env_block);

   return (pid_t) pi->hProcess;

  error:
-  if (env_block)
-    free (env_block);
-  if (cmdline)
-    free (cmdline);
-  if (full_executable)
-    free (full_executable);
+  free (env_block);
+  free (cmdline);
+  free (full_executable);

   return (pid_t) -1;
 }
diff --git a/libiberty/regex.c b/libiberty/regex.c
index 420c7f4..d65eedb 100644
--- a/libiberty/regex.c
+++ b/libiberty/regex.c
@@ -4970,7 +4970,7 @@  weak_alias (__re_search_2, re_search_2)
 #ifdef MATCH_MAY_ALLOCATE
 # define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL
 #else
-# define FREE_VAR(var) if (var) free (var); var = NULL
+# define FREE_VAR(var) free (var); var = NULL
 #endif

 #ifdef WCHAR
@@ -8111,20 +8111,17 @@  weak_alias (__regerror, regerror)
 void
 regfree (regex_t *preg)
 {
-  if (preg->buffer != NULL)
-    free (preg->buffer);
+  free (preg->buffer);
   preg->buffer = NULL;

   preg->allocated = 0;
   preg->used = 0;

-  if (preg->fastmap != NULL)
-    free (preg->fastmap);
+  free (preg->fastmap);
   preg->fastmap = NULL;
   preg->fastmap_accurate = 0;

-  if (preg->translate != NULL)
-    free (preg->translate);
+  free (preg->translate);
   preg->translate = NULL;
 }
 #ifdef _LIBC
diff --git a/libjava/classpath/native/fdlibm/dtoa.c b/libjava/classpath/native/fdlibm/dtoa.c
index 458e629..92aa793 100644
--- a/libjava/classpath/native/fdlibm/dtoa.c
+++ b/libjava/classpath/native/fdlibm/dtoa.c
@@ -916,6 +916,5 @@  _DEFUN (_dtoa,
 	  l = next;
 	}
     }
-  if (reent._freelist)
-    free (reent._freelist);
+  free (reent._freelist);
 }
diff --git a/libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.c b/libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.c
index e0caa47..c6a27ff 100644
--- a/libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.c
+++ b/libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.c
@@ -343,8 +343,7 @@  Java_gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_create_1named_1pipe

   if (mkfifo (jpipeline->priv->name, 0600) < 0)
     {
-      if (jpipeline->priv->name != NULL)
-        free (jpipeline->priv->name);
+      free (jpipeline->priv->name);
       return JNI_FALSE;
     }

@@ -353,8 +352,7 @@  Java_gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_create_1named_1pipe
   if (name == NULL)
     {
       cpio_removeFile (jpipeline->priv->name);
-      if (jpipeline->priv->name != NULL)
-        free (jpipeline->priv->name);
+      free (jpipeline->priv->name);

       return JNI_FALSE;
     }
diff --git a/libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c b/libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c
index a6076f2..5f0b507 100644
--- a/libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c
+++ b/libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c
@@ -298,8 +298,7 @@  done:
   while (num_strings > 0)
     free (strings[--num_strings]);
   free (strings);
-  if (dir != NULL)
-    free(dir);
+  free(dir);
   /* Done */
   return;

diff --git a/libjava/gnu/classpath/natSystemProperties.cc b/libjava/gnu/classpath/natSystemProperties.cc
index e259304..c2adb34 100644
--- a/libjava/gnu/classpath/natSystemProperties.cc
+++ b/libjava/gnu/classpath/natSystemProperties.cc
@@ -275,8 +275,7 @@  gnu::classpath::SystemProperties::insertSystemProperties (::java::util::Properti
       if (buffer == NULL)
 	free (orig_buf);
     }
-  if (buffer != NULL)
-    free (buffer);
+  free (buffer);
 #endif /* HAVE_UNISTD_H */
 #endif /* HAVE_GETCWD */

diff --git a/libjava/include/java-stack.h b/libjava/include/java-stack.h
index 40ce825..b3f3ac8 100644
--- a/libjava/include/java-stack.h
+++ b/libjava/include/java-stack.h
@@ -165,11 +165,9 @@  struct _Jv_AddrInfo
       // they are.

 #ifdef WIN32
-      if (file_name)
-        free ((void *)file_name);
+      free ((void *)file_name);

-      if (sym_name)
-        free ((void *)sym_name);
+      free ((void *)sym_name);
 #endif /* WIN32 */
     }
 };
diff --git a/libstdc++-v3/libsupc++/del_opnt.cc b/libstdc++-v3/libsupc++/del_opnt.cc
index 75051d5..29eab10 100644
--- a/libstdc++-v3/libsupc++/del_opnt.cc
+++ b/libstdc++-v3/libsupc++/del_opnt.cc
@@ -31,6 +31,5 @@  extern "C" void free (void *);
 _GLIBCXX_WEAK_DEFINITION void
 operator delete (void *ptr, const std::nothrow_t&) throw ()
 {
-  if (ptr)
-    free (ptr);
+  free (ptr);
 }
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index 64a0164..6f8a387 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -312,8 +312,7 @@  free_1 (void)
 	{
 	  struct ld_plugin_symbol *s = &symtab->syms[j];
 	  free (s->name);
-	  if (s->comdat_key)
-	    free (s->comdat_key);
+	  free (s->comdat_key);
 	}
       free (symtab->syms);
       symtab->syms = NULL;
@@ -342,8 +341,7 @@  free_2 (void)
   claimed_files = NULL;
   num_claimed_files = 0;

-  if (arguments_file_name)
-    free (arguments_file_name);
+  free (arguments_file_name);
   arguments_file_name = NULL;
 }

diff --git a/zlib/contrib/minizip/unzip.c b/zlib/contrib/minizip/unzip.c
index 9ad4766..644ef1b 100644
--- a/zlib/contrib/minizip/unzip.c
+++ b/zlib/contrib/minizip/unzip.c
@@ -78,7 +78,7 @@  woven in by Terry Thorsen 1/2003.
 # define ALLOC(size) (malloc(size))
 #endif
 #ifndef TRYFREE
-# define TRYFREE(p) {if (p) free(p);}
+# define TRYFREE(p) {free(p);}
 #endif

 #define SIZECENTRALDIRITEM (0x2e)
diff --git a/zlib/contrib/minizip/zip.c b/zlib/contrib/minizip/zip.c
index 7fbe002..945f271 100644
--- a/zlib/contrib/minizip/zip.c
+++ b/zlib/contrib/minizip/zip.c
@@ -50,7 +50,7 @@ 
 # define ALLOC(size) (malloc(size))
 #endif
 #ifndef TRYFREE
-# define TRYFREE(p) {if (p) free(p);}
+# define TRYFREE(p) {free(p);}
 #endif

 /*
diff --git a/zlib/examples/gun.c b/zlib/examples/gun.c
index bfec590..57d0cda 100644
--- a/zlib/examples/gun.c
+++ b/zlib/examples/gun.c
@@ -681,7 +681,7 @@  int main(int argc, char **argv)
                 outname[len] = 0;
             }
             ret = gunzip(&strm, *argv, outname, test);
-            if (outname != NULL) free(outname);
+            free(outname);
             if (ret) break;
         } while (argv++, --argc);
     else
diff --git a/zlib/examples/gzappend.c b/zlib/examples/gzappend.c
index e9e878e..7d036fc 100644
--- a/zlib/examples/gzappend.c
+++ b/zlib/examples/gzappend.c
@@ -453,7 +453,7 @@  local void gztack(char *name, int gd, z_stream *strm, int last)

     /* clean up and return */
     free(out);
-    if (in != NULL) free(in);
+    free(in);
     if (fd > 0) close(fd);
 }

diff --git a/zlib/examples/gzjoin.c b/zlib/examples/gzjoin.c
index 129347c..d3a0534 100644
--- a/zlib/examples/gzjoin.c
+++ b/zlib/examples/gzjoin.c
@@ -88,8 +88,7 @@  local void bclose(bin *in)
     if (in != NULL) {
         if (in->fd != -1)
             close(in->fd);
-        if (in->buf != NULL)
-            free(in->buf);
+        free(in->buf);
         free(in);
     }
 }
diff --git a/zlib/gzio.c b/zlib/gzio.c
index a358774..36098c9 100644
--- a/zlib/gzio.c
+++ b/zlib/gzio.c
@@ -41,7 +41,7 @@  extern void   free   OF((voidpf ptr));
 #endif

 #define ALLOC(size) malloc(size)
-#define TRYFREE(p) {if (p) free(p);}
+#define TRYFREE(p) {free(p);}

 static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */

--
1.7.4.1.21.g4cc62


From 8e335c35418f25ec2bf7f009b57c0bad9db0130a Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Mon, 3 Jan 2011 16:55:58 +0100
Subject: [PATCH 3/4] remove unnecessary if-before-free tests (2 more, with braces)

git grep -l -z "$free *(" \
  | xargs -0 useless-if-before-free -l --name="$free" \
  | xargs -0 perl -0777 -pi -e \
     's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s*\{\s*('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\);)\s*\}[^\n]*$/$2/gms'
---
 libiberty/cplus-dem.c                        |   10 ++--------
 libiberty/spaces.c                           |    5 +----
 libjava/classpath/native/jni/classpath/jcl.c |    5 +----
 3 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c
index e948487..629d77b 100644
--- a/libiberty/cplus-dem.c
+++ b/libiberty/cplus-dem.c
@@ -1215,14 +1215,8 @@  squangle_mop_up (struct work_stuff *work)
 {
   /* clean up the B and K type mangling types. */
   forget_B_and_K_types (work);
-  if (work -> btypevec != NULL)
-    {
-      free ((char *) work -> btypevec);
-    }
-  if (work -> ktypevec != NULL)
-    {
-      free ((char *) work -> ktypevec);
-    }
+  free ((char *) work -> btypevec);
+  free ((char *) work -> ktypevec);
 }


diff --git a/libiberty/spaces.c b/libiberty/spaces.c
index 67481c9..69d7a2d 100644
--- a/libiberty/spaces.c
+++ b/libiberty/spaces.c
@@ -53,10 +53,7 @@  spaces (int count)

   if (count > maxsize)
     {
-      if (buf)
-	{
-	  free (buf);
-	}
+      free (buf);
       buf = (char *) malloc (count + 1);
       if (buf == (char *) 0)
 	return 0;
diff --git a/libjava/classpath/native/jni/classpath/jcl.c b/libjava/classpath/native/jni/classpath/jcl.c
index 0180ab9..d25ae8a 100644
--- a/libjava/classpath/native/jni/classpath/jcl.c
+++ b/libjava/classpath/native/jni/classpath/jcl.c
@@ -167,10 +167,7 @@  JCL_realloc (JNIEnv * env, void *ptr, size_t size)
 JNIEXPORT void JNICALL
 JCL_free (JNIEnv * env __attribute__ ((unused)), void *p)
 {
-  if (p != NULL)
-    {
-      free (p);
-    }
+  free (p);
 }

 JNIEXPORT const char *JNICALL
--
1.7.4.1.21.g4cc62


From 62edd1f37e2c06c2ace911d001a64794477866e3 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Mon, 3 Jan 2011 17:00:23 +0100
Subject: [PATCH 4/4] adjust for one erroneous (syntax-error-inducing) transformation

---
 gcc/fortran/gfortranspec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gcc/fortran/gfortranspec.c b/gcc/fortran/gfortranspec.c
index 477e4a0..4d939a0 100644
--- a/gcc/fortran/gfortranspec.c
+++ b/gcc/fortran/gfortranspec.c
@@ -473,7 +473,7 @@  int
 lang_specific_pre_link (void)
 {
   free (spec_file);
-  else if (library)
+  if (spec_file == NULL && library)
     do_spec ("%:include(libgfortran.spec)");

   return 0;