[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 03/37] qga: free the whole blacklist
From: |
Marc-André Lureau |
Subject: |
Re: [Qemu-devel] [PATCH v2 03/37] qga: free the whole blacklist |
Date: |
Thu, 28 Jul 2016 17:36:59 -0400 (EDT) |
----- Original Message -----
> On 07/28/2016 08:37 AM, address@hidden wrote:
> > From: Marc-André Lureau <address@hidden>
> >
> > Free the list, not just the elements.
> >
> > Signed-off-by: Marc-André Lureau <address@hidden>
> > ---
> > qga/main.c | 8 ++------
> > 1 file changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/qga/main.c b/qga/main.c
> > index 4c3b2c7..67be90b 100644
> > --- a/qga/main.c
> > +++ b/qga/main.c
> > @@ -1175,6 +1175,8 @@ static void config_free(GAConfig *config)
> > #ifdef CONFIG_FSFREEZE
> > g_free(config->fsfreeze_hook);
> > #endif
> > + g_list_foreach(config->blacklist, (GFunc)g_free, NULL);
>
> What an ugly cast - undefined behavior according to C. But it happens to
> work on all ABI that we support (calling a unary function as cast to
> appear as a binary function silently ignores the second argument), so I
> could sort of live with it, if it made the patch arguably smaller due to
> fewer lines of code than required for a type-correct solution.
Note that's how glib implements g_slist_free_full() and others, I just used the
same common code/style
>
> > + g_list_free(config->blacklist);
> > g_free(config);
> > }
> >
> > @@ -1310,11 +1312,6 @@ static int run_agent(GAState *s, GAConfig *config)
> > return EXIT_SUCCESS;
> > }
> >
> > -static void free_blacklist_entry(gpointer entry, gpointer unused)
> > -{
> > - g_free(entry);
> > -}
>
> On the other hand, we already had EXACTLY the type-correct forwarder
> function in place (it just needs to be hoisted earlier before the point
> where you use it).
>
> So I would really prefer that v3 use free_blacklist_entry() rather than
> (GFunc)g_free as the argument to g_list_foreach().
ok ;)
- [Qemu-devel] [PATCH v2 00/37] Various memory leak fixes, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 04/37] qga: free remaining leaking state, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 06/37] tests: fix test-vmstate leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 05/37] tests: fix test-cutils leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 07/37] tests: fix test-iov leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 08/37] qdist: fix entries memory leak, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 09/37] tests: fix check-qom-interface leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 10/37] tests: fix check-qom-proplist leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 11/37] tests: fix small leak in test-io-channel-command, marcandre . lureau, 2016/07/28