[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 08/15] qstring: Add qstring_wrap_str()
From: |
Marc-André Lureau |
Subject: |
Re: [Qemu-devel] [PATCH v6 08/15] qstring: Add qstring_wrap_str() |
Date: |
Tue, 11 Oct 2016 15:25:13 +0000 |
Hi
On Tue, Oct 11, 2016 at 7:05 PM Eric Blake <address@hidden> wrote:
> On 10/11/2016 10:04 AM, Eric Blake wrote:
> > On 10/11/2016 06:08 AM, Marc-André Lureau wrote:
> >
> >>> +++ b/block.c
> >>> @@ -1640,7 +1640,8 @@ static BlockDriverState
> >>> *bdrv_append_temp_snapshot(BlockDriverState *bs,
> >>> qdict_put(snapshot_options, "file.driver",
> >>> qstring_from_str("file"));
> >>> qdict_put(snapshot_options, "file.filename",
> >>> - qstring_from_str(tmp_filename));
> >>> + qstring_wrap_str(tmp_filename));
> >>> + tmp_filename = NULL;
> >>> qdict_put(snapshot_options, "driver",
> >>> qstring_from_str("qcow2"));
> >>>
> >>>
> >> You could also remove g_free(tmp_filename) from the normal return path
> >> (this may please static analyzers).
> >
> > No. g_free(NULL) is safe, but we can also reach the 'out' label with
> > tmp_filename still malloc'd prior to the place where we transfer it
> > here, so the g_free() in the cleanup label is still required. The
> > assignment to NULL here prevents a double free. The patch is correct
> as-is.
>
> Spoke too soon. I see what you're saying - the normal return path now
> has a dead g_free(NULL). It won't cause any grief to the static
> analyzers, but it is a useless no-op function call, so I can indeed trim
> it (the one before the label, not the one after).
>
static analyzers could catch the fact that you always call g_free(NULL) in
this code path, please remove it.
> --
> Eric Blake eblake redhat com +1-919-301-3266 <+1%20919-301-3266>
> Libvirt virtualization library http://libvirt.org
>
> --
Marc-André Lureau
- Re: [Qemu-devel] [PATCH v6 12/15] qapi: Support pretty printing in JSON output visitor, (continued)
- [Qemu-devel] [PATCH v6 11/15] qapi: Add JSON output visitor, Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 10/15] tests: Test qobject_to_json() pretty formatting, Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 14/15] qapi: Add 'any' support to JSON output, Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 13/15] qobject: Implement qobject_to_json() atop JSON visitor, Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 09/15] qobject: Consolidate qobject_to_json() calls, Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 08/15] qstring: Add qstring_wrap_str(), Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 08.5/15] fixup! qstring: Add qstring_wrap_str(), Eric Blake, 2016/10/11
[Qemu-devel] [PATCH v6 15/15] qemu-img: Use new JSON output formatter, Eric Blake, 2016/10/10
Re: [Qemu-devel] [PATCH v6 00/15] Add qapi-to-JSON visitor, Marc-André Lureau, 2016/10/11