From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: Greg Kurz <groug@kaod.org>
Subject: Re: [PATCH 2/2] hw/9pfs: use g_autofree in v9fs_walk() where possible
Date: Fri, 20 Aug 2021 14:23:26 +0200 [thread overview]
Message-ID: <12832142.34yICVTDIk@silver> (raw)
In-Reply-To: <20210820124031.6ea5e042@bahia.lan>
On Freitag, 20. August 2021 12:40:31 CEST Greg Kurz wrote:
> On Tue, 17 Aug 2021 15:46:50 +0200
>
> Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:
> > Suggested-by: Greg Kurz <groug@kaod.org>
> > Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > ---
> >
> > hw/9pfs/9p.c | 7 +++----
> > 1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> > index 4d642ab12a..c857b31321 100644
> > --- a/hw/9pfs/9p.c
> > +++ b/hw/9pfs/9p.c
> > @@ -1703,11 +1703,12 @@ static bool same_stat_id(const struct stat *a,
> > const struct stat *b)>
> > static void coroutine_fn v9fs_walk(void *opaque)
> > {
> >
> > int name_idx;
> >
> > - V9fsQID *qids = NULL;
> > + g_autofree V9fsQID *qids = NULL;
> >
> > int i, err = 0;
> > V9fsPath dpath, path, *pathes = NULL;
> > uint16_t nwnames;
> >
> > - struct stat stbuf, fidst, *stbufs = NULL;
> > + struct stat stbuf, fidst;
> > + g_autofree struct stat *stbufs = NULL;
> >
> > size_t offset = 7;
> > int32_t fid, newfid;
> > V9fsString *wnames = NULL;
> >
> > @@ -1872,8 +1873,6 @@ out_nofid:
> > v9fs_path_free(&pathes[name_idx]);
> >
> > }
> > g_free(wnames);
> >
> > - g_free(qids);
> > - g_free(stbufs);
> >
> > g_free(pathes);
>
> It seems that wnames and pathes could be converted to
> g_autofree as well or I'm missing something ?
Yeah, I mentioned that in the cover letter. Those two are omitted in this
patch because they contain dynamically allocated memory per array element
which need to be freed individually before freeing the array.
So those two would probably require custom cleanup handlers.
>
> Feel free to add my R-b with or without that extra change.
>
> Reviewed-by: Greg Kurz <groug@kaod.org>
Thanks!
>
> > }
> >
> > }
Best regards,
Christian Schoenebeck
next prev parent reply other threads:[~2021-08-20 12:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 13:52 [PATCH 0/2] 9pfs: v9fs_walk() cleanup Christian Schoenebeck
2021-08-17 12:38 ` [PATCH 1/2] hw/9pfs: avoid 'path' copy in v9fs_walk() Christian Schoenebeck
2021-08-20 10:35 ` Greg Kurz
2021-08-20 12:19 ` Christian Schoenebeck
2021-08-17 13:46 ` [PATCH 2/2] hw/9pfs: use g_autofree in v9fs_walk() where possible Christian Schoenebeck
2021-08-17 14:10 ` Philippe Mathieu-Daudé
2021-08-20 10:40 ` Greg Kurz
2021-08-20 12:23 ` Christian Schoenebeck [this message]
2021-08-20 12:34 ` Greg Kurz
2021-08-20 12:49 ` Christian Schoenebeck
2021-08-20 14:30 ` [PATCH 0/2] 9pfs: v9fs_walk() cleanup Christian Schoenebeck
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=12832142.34yICVTDIk@silver \
--to=qemu_oss@crudebyte.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
/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).