From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Richard Henderson <richard.henderson@linaro.org>,
Greg Kurz <groug@kaod.org>
Subject: Re: [PATCH 1/5] 9pfs: introduce P9Array
Date: Fri, 01 Oct 2021 17:27:06 +0200 [thread overview]
Message-ID: <3721374.iaAHClRopi@silver> (raw)
In-Reply-To: <YVcmX/lKmHrsivVJ@redhat.com>
On Freitag, 1. Oktober 2021 17:16:47 CEST Daniel P. Berrangé wrote:
> On Fri, Oct 01, 2021 at 04:26:17PM +0200, Christian Schoenebeck wrote:
> > Implements deep auto free of arrays while retaining common C-style
> > squared bracket access. Main purpose of this API is to get rid of
> > error prone individual array deallocation pathes in user code, i.e.
> >
> > turning something like this:
> > void doSomething(size_t n) {
> >
> > Foo *foos = malloc(n * sizeof(Foo));
> > for (...) {
> >
> > foos[i].s = malloc(...);
> > if (...) {
> >
> > goto out;
> >
> > }
> >
> > }
> >
> > out:
> > if (...) {
> >
> > for (...) {
> >
> > /* deep deallocation */
> > free(foos[i].s);
> >
> > }
> > /* array deallocation */
> > free(foos);
> >
> > }
> >
> > }
> >
> > into something more simple and safer like:
> > void doSomething(size_t n) {
> >
> > P9ARRAY_REF(Foo) foos = NULL;
> > P9ARRAY_NEW(Foo, foos, n);
> > for (...) {
> >
> > foos[i].s = malloc(...);
> > if (...) {
> >
> > return; /* array auto freed here */
> >
> > }
> >
> > }
> > /* array auto freed here */
> >
> > }
>
> As explained before, I'm against the idea of introducing new ways
> to automatically free local variables that are not using g_auto*
> functionality. It is not following the QEMU wide coding style
> that is documented.
Yes, your concerns are linked in the cover letter. And I also made it clear
that what you suggested does not fit either. So my position has not changed.
Best regards,
Christian Schoenebeck
next prev parent reply other threads:[~2021-10-01 15:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 14:25 [PATCH 0/5] 9pfs: introduce P9Array Christian Schoenebeck
2021-10-01 14:26 ` [PATCH 1/5] " Christian Schoenebeck
2021-10-01 15:16 ` Daniel P. Berrangé
2021-10-01 15:27 ` Christian Schoenebeck [this message]
2021-10-01 14:27 ` [PATCH 2/5] fsdev/p9array.h: check scalar type in P9ARRAY_NEW() Christian Schoenebeck
2021-10-01 14:27 ` [PATCH 3/5] 9pfs: make V9fsString usable via P9Array API Christian Schoenebeck
2021-10-01 14:27 ` [PATCH 4/5] 9pfs: make V9fsPath " Christian Schoenebeck
2021-10-01 14:27 ` [PATCH 5/5] 9pfs: use P9Array in v9fs_walk() Christian Schoenebeck
2021-10-14 13:25 ` [PATCH 0/5] 9pfs: introduce P9Array 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=3721374.iaAHClRopi@silver \
--to=qemu_oss@crudebyte.com \
--cc=berrange@redhat.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 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.