From: Markus Armbruster <armbru@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [PATCH 25/27] include/qapi: add g_autoptr support for qobject types
Date: Wed, 16 Mar 2022 13:59:12 +0100 [thread overview]
Message-ID: <87fsnixdcv.fsf@pond.sub.org> (raw)
In-Reply-To: <CAMxuvazmKfOcKo2dJeduvifrYFOMYCVgCDkC4qak0e8yioCWOQ@mail.gmail.com> ("Marc-André Lureau"'s message of "Wed, 16 Mar 2022 16:37:39 +0400")
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> Hi
>
> On Wed, Mar 16, 2022 at 4:31 PM Markus Armbruster <armbru@redhat.com> wrote:
>>
>> marcandre.lureau@redhat.com writes:
>>
>> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
>> >
>> > Add small inline wrappers for qobject_unref() calls, which is a macro.
>> >
>> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> > ---
>> > include/qapi/qmp/qbool.h | 6 ++++++
>> > include/qapi/qmp/qdict.h | 6 ++++++
>> > include/qapi/qmp/qlist.h | 8 +++++++-
>> > include/qapi/qmp/qnull.h | 6 ++++++
>> > include/qapi/qmp/qnum.h | 6 ++++++
>> > include/qapi/qmp/qstring.h | 6 ++++++
>> > 6 files changed, 37 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/include/qapi/qmp/qbool.h b/include/qapi/qmp/qbool.h
>> > index 2f888d10573f..52b1c5c15280 100644
>> > --- a/include/qapi/qmp/qbool.h
>> > +++ b/include/qapi/qmp/qbool.h
>> > @@ -21,6 +21,12 @@ struct QBool {
>> > bool value;
>> > };
>> >
>> > +static inline void qbool_unref(QBool *q) {
>> > + qobject_unref(q);
>> > +}
>> > +
>> > +G_DEFINE_AUTOPTR_CLEANUP_FUNC(QBool, qbool_unref)
>> > +
>>
>> You need the wrapper function around the wrapper macro qobject_unref(),
>> because
>>
>> G_DEFINE_AUTOPTR_CLEANUP_FUNC(QBool, qobject_unref_impl)
>>
>> dies with "passing argument 1 of ‘qobject_unref_impl’ from incompatible
>> pointer type [-Wincompatible-pointer-types]". Okay.
>
> Yeah, unfortunately. There might be other tricks possible, but they
> would likely be less obvious.
>
>>
>> Style nitpick: a function's opening brace goes on its own line:
>>
>> static inline void qbool_unref(QBool *q)
>> {
>> qobject_unref(q);
>> }
>>
>
> right
>
>> Moreover, I prefer to put code in headers only when there's a real need.
>> I don't see one here. Most existing uses of
>
> I agree, I generally don't like inline. However, simple one-liner
> wrapper kinda fit. I was even tempted to use extra _ at the end of the
> function to prevent usage outside of the macro, but decided that
> wouldn't be much better.
>
> Btw, what's' your rule for using "static inline" in headers then :) ?
Demonstrated performance improvement would be compelling.
Occasionally, there's no good .c home for the function, and putting it
in the header is overall less bad than creating a .c for it.
>> G_DEFINE_AUTOPTR_CLEANUP_FUNC() use a plain extern function.
[...]
prev parent reply other threads:[~2022-03-16 13:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-16 9:54 [PATCH 25/27] include/qapi: add g_autoptr support for qobject types marcandre.lureau
2022-03-16 12:30 ` Markus Armbruster
2022-03-16 12:37 ` Marc-André Lureau
2022-03-16 12:59 ` Markus Armbruster [this message]
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=87fsnixdcv.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=marcandre.lureau@redhat.com \
--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 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.