From: Eric Blake <eblake@redhat.com>
To: Gonglei <arei.gonglei@huawei.com>
Cc: "kwolf@redhat.com" <kwolf@redhat.com>,
"Huangweidong (C)" <weidong.huang@huawei.com>,
Zhanghailiang <zhang.zhanghailiang@huawei.com>,
"qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"stefanha@redhat.com" <stefanha@redhat.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] oslib-posix: change free to g_free
Date: Fri, 10 Oct 2014 21:44:59 -0600 [thread overview]
Message-ID: <5438A7BB.3060109@redhat.com> (raw)
In-Reply-To: <5438A4E2.4090007@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 864 bytes --]
On 10/10/2014 09:32 PM, Gonglei wrote:
>>> Actually, I had noted that C standard says it is a no-operation.
>>> But that doesn't mean that every C-library handles it like that.
>>
>> EVERY libc that is C89 compliant handles it like that. The last
>> platform that failed on free(NULL) was SunOS 4, which is such
>> museum-ware it's not funny. There is no need to cater to platforms from
>> 25 years ago.
>
> But why some callers make a check,
> but some other callers don't do this check?
Because some people haven't learned that free(NULL) is safe yet. You're
welcome to simplify code as you touch it.
> Can I consider those check is superfluous?
Yes. Checking for NULL before calling free() or g_free() is wasted effort.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
next prev parent reply other threads:[~2014-10-11 3:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-11 2:54 [Qemu-devel] [PATCH] oslib-posix: change free to g_free arei.gonglei
2014-10-11 3:10 ` zhanghailiang
2014-10-11 3:21 ` Gonglei
2014-10-11 3:26 ` Eric Blake
2014-10-11 3:32 ` Gonglei
2014-10-11 3:44 ` Eric Blake [this message]
2014-10-11 3:47 ` Gonglei
2014-10-11 3:23 ` Eric Blake
2014-10-12 7:44 ` Kevin Wolf
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=5438A7BB.3060109@redhat.com \
--to=eblake@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=stefanha@redhat.com \
--cc=weidong.huang@huawei.com \
--cc=zhang.zhanghailiang@huawei.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;
as well as URLs for NNTP newsgroup(s).