Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@efficios.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: remove unnecessary NULL checks before xfree
Date: Thu, 21 May 2020 17:59:14 +0100	[thread overview]
Message-ID: <9267cb3e-36ae-5d05-d636-37ef2d177190@redhat.com> (raw)
In-Reply-To: <20200521151032.3116197-1-simon.marchi@efficios.com>

On 5/21/20 4:10 PM, Simon Marchi via Gdb-patches wrote:
> I was inspired by a series of patches merged by Alan Modra in the other
> projects, so I did the same in GDB with a bit of Coccinelle and grep.
> 
> This patch removes the unnecessary NULL checks before calls to xfree.
> They are unnecessary because xfree already does a NULL check.  Since
> free is supposed to handle NULL values correctly, the NULL check in
> xfree itself is also questionable, but I've left it there for now.

xfree was invented exactly because some ancient hosts did not handle
free(NULL) gracefully:

  https://sourceware.org/legacy-ml/gdb/2000-11/msg00276.html

I'd like to believe that such hosts are long gone.

(It's a reasonable micro-optimization to check for NULL
before calling free, to avoid the function call overhead,
but I don't think this is the motivation for any of the
cases here.  Since xfree is inline, I guess we're applying
that micro-optimization everywhere, by chance.)

Thanks,
Pedro Alves



  parent reply	other threads:[~2020-05-21 16:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21 15:10 Simon Marchi
2020-05-21 15:23 ` Tom Tromey
2020-05-21 17:12   ` Simon Marchi
2020-05-21 16:59 ` Pedro Alves [this message]
2020-05-21 17:11   ` Simon Marchi

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=9267cb3e-36ae-5d05-d636-37ef2d177190@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /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