[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v2 1/2] qapi: Inline qmp_marshal_output() functions
From: |
Eric Blake |
Subject: |
Re: [RFC PATCH v2 1/2] qapi: Inline qmp_marshal_output() functions |
Date: |
Wed, 9 Jun 2021 15:29:52 -0500 |
User-agent: |
NeoMutt/20210205 |
On Wed, Jun 09, 2021 at 08:49:54PM +0200, Philippe Mathieu-Daudé wrote:
> In case we need to use QAPI types but no QAPI command / QAPI event
> actually use them, the generated qmp_marshal_output() function will
> trigger the compiler 'unused-function' warnings.
> To prevent that, emit these functions inlined: the compiler will
> ignore such unused functions.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> RFC: No clue about QAPI...
> Tested with GCC. If the compiler is picky we could use the 'unused'
> function attribute.
And I have no clue if clang will warn about an unused inline function.
Going with the compiler attribute seems safer and just as easy to do
in the same two-line change (remember, the "unused" attribute merely
means "suppress warnings if I don't use this", and not "warn me if I
use it in spite of calling it unused").
> ---
> scripts/qapi/commands.py | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py
> index 0e13d510547..bbed776a909 100644
> --- a/scripts/qapi/commands.py
> +++ b/scripts/qapi/commands.py
> @@ -91,8 +91,8 @@ def gen_call(name: str,
> def gen_marshal_output(ret_type: QAPISchemaType) -> str:
> return mcgen('''
>
> -static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in,
> - QObject **ret_out, Error **errp)
> +static inline void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in,
> + QObject **ret_out, Error **errp)
On the other hand, the qapi generator is smart enough to only output
introspection data for qapi types that were actually used by a command
or event, so how is that working, and why is it not also being used to
elide the generation of unused qmp_marshal_output_FOO functions? This
is where I'll have to defer to Markus.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
- [PATCH v2 0/2] tpm: Return QMP error when TPM is disabled in build, Philippe Mathieu-Daudé, 2021/06/09
- [RFC PATCH v2 1/2] qapi: Inline qmp_marshal_output() functions, Philippe Mathieu-Daudé, 2021/06/09
- Re: [RFC PATCH v2 1/2] qapi: Inline qmp_marshal_output() functions,
Eric Blake <=
- Re: [RFC PATCH v2 1/2] qapi: Inline qmp_marshal_output() functions, Markus Armbruster, 2021/06/10
- Re: [RFC PATCH v2 1/2] qapi: Inline qmp_marshal_output() functions, Philippe Mathieu-Daudé, 2021/06/10
- Re: [RFC PATCH v2 1/2] qapi: Inline qmp_marshal_output() functions, Markus Armbruster, 2021/06/10
- Re: [RFC PATCH v2 1/2] qapi: Inline qmp_marshal_output() functions, Philippe Mathieu-Daudé, 2021/06/10
- Re: [RFC PATCH v2 1/2] qapi: Inline qmp_marshal_output() functions, Markus Armbruster, 2021/06/11
- Re: [RFC PATCH v2 1/2] qapi: Inline qmp_marshal_output() functions, Stefan Berger, 2021/06/11
[PATCH v2 2/2] tpm: Return QMP error when TPM is disabled in build, Philippe Mathieu-Daudé, 2021/06/09