avoid useless if-before-free tests

Jim Meyering jim@meyering.net
Tue Mar 8 17:17:00 GMT 2011

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.

More information about the Java-patches mailing list