From: Andrew Haley <aph@redhat.com>
To: Martin Ettl <ettl.martin@gmx.de>
Cc: java@gcc.gnu.org
Subject: Re: found redundant code in file natSystemProperties.cc
Date: Wed, 29 Jul 2009 18:25:00 -0000 [thread overview]
Message-ID: <4A709401.4070808@redhat.com> (raw)
In-Reply-To: <20090728042115.158890@gmx.net>
Martin Ettl wrote:
> Hello friends,
>
> i have checked the sources of gcc-4.4.1 with the static code analysis tool cppcheck. It brought up an issue in file gcc-4.4.1/libjava/gnu/classpath/natSystemProperties.cc at line 278. Lets take a look at the sourcecode:
> 278 if (buffer != NULL)
> free (buffer);
> ....
>
> Here the line 278 is redundant, because it is safe to deallocate a NULL-Pointer! In other words, the if-statement can be removed.
Well yes, but it saves a library call.
Harbison and Steele note "If the argument to free is a null pointer
then no action should occur, but this has been known to cause trouble
in some C implementations." This is probably just ancient history,
though.
Andrew.
prev parent reply other threads:[~2009-07-29 18:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-28 4:21 Martin Ettl
2009-07-29 18:25 ` Andrew Haley [this message]
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=4A709401.4070808@redhat.com \
--to=aph@redhat.com \
--cc=ettl.martin@gmx.de \
--cc=java@gcc.gnu.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).