From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: <arei.gonglei@huawei.com>, <qemu-devel@nongnu.org>
Cc: kwolf@redhat.com, qemu-trivial@nongnu.org,
weidong.huang@huawei.com, stefanha@redhat.com,
pbonzini@redhat.com
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] oslib-posix: change free to g_free
Date: Sat, 11 Oct 2014 11:10:41 +0800 [thread overview]
Message-ID: <54389FB1.8040207@huawei.com> (raw)
In-Reply-To: <1412996048-6384-1-git-send-email-arei.gonglei@huawei.com>
On 2014/10/11 10:54, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> The caller of qemu_vfree() maybe not check whether parameter
> ptr pointer is NULL or not, such as vpc_open().
> Using g_free() is more safe.
>
It seems that free(NULL) is harmless.
From section 7.20.3.2/2 of the C99 standard:
The free function causes the space pointed to by ptr to be deallocated, that is,
made available for further allocation. If ptr is a null pointer, no action occurs.
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> util/oslib-posix.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index 016a047..ca435d0 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -153,7 +153,7 @@ void *qemu_anon_ram_alloc(size_t size)
> void qemu_vfree(void *ptr)
> {
> trace_qemu_vfree(ptr);
> - free(ptr);
> + g_free(ptr);
> }
>
> void qemu_anon_ram_free(void *ptr, size_t size)
>
WARNING: multiple messages have this Message-ID (diff)
From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: arei.gonglei@huawei.com, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-trivial@nongnu.org,
weidong.huang@huawei.com, stefanha@redhat.com,
pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH] oslib-posix: change free to g_free
Date: Sat, 11 Oct 2014 11:10:41 +0800 [thread overview]
Message-ID: <54389FB1.8040207@huawei.com> (raw)
In-Reply-To: <1412996048-6384-1-git-send-email-arei.gonglei@huawei.com>
On 2014/10/11 10:54, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> The caller of qemu_vfree() maybe not check whether parameter
> ptr pointer is NULL or not, such as vpc_open().
> Using g_free() is more safe.
>
It seems that free(NULL) is harmless.
From section 7.20.3.2/2 of the C99 standard:
The free function causes the space pointed to by ptr to be deallocated, that is,
made available for further allocation. If ptr is a null pointer, no action occurs.
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> util/oslib-posix.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index 016a047..ca435d0 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -153,7 +153,7 @@ void *qemu_anon_ram_alloc(size_t size)
> void qemu_vfree(void *ptr)
> {
> trace_qemu_vfree(ptr);
> - free(ptr);
> + g_free(ptr);
> }
>
> void qemu_anon_ram_free(void *ptr, size_t size)
>
next prev parent reply other threads:[~2014-10-11 3:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-11 2:54 [Qemu-trivial] [PATCH] oslib-posix: change free to g_free arei.gonglei
2014-10-11 2:54 ` [Qemu-devel] " arei.gonglei
2014-10-11 3:10 ` zhanghailiang [this message]
2014-10-11 3:10 ` zhanghailiang
2014-10-11 3:21 ` [Qemu-trivial] " Gonglei
2014-10-11 3:21 ` Gonglei
2014-10-11 3:26 ` [Qemu-trivial] " Eric Blake
2014-10-11 3:26 ` Eric Blake
2014-10-11 3:32 ` [Qemu-trivial] " Gonglei
2014-10-11 3:32 ` Gonglei
2014-10-11 3:44 ` [Qemu-trivial] " Eric Blake
2014-10-11 3:44 ` Eric Blake
2014-10-11 3:47 ` [Qemu-trivial] " Gonglei
2014-10-11 3:47 ` Gonglei
2014-10-11 3:23 ` [Qemu-trivial] " Eric Blake
2014-10-11 3:23 ` Eric Blake
2014-10-12 7:44 ` [Qemu-trivial] " Kevin Wolf
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=54389FB1.8040207@huawei.com \
--to=zhang.zhanghailiang@huawei.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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.