qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 23/28] qapi tpm: Elide redundant has_FOO in generated C


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2 23/28] qapi tpm: Elide redundant has_FOO in generated C
Date: Tue, 18 Oct 2022 14:23:38 +0200

On Tue, 18 Oct 2022 at 14:12, Stefan Berger <stefanb@linux.ibm.com> wrote:
> On 10/18/22 08:01, Philippe Mathieu-Daudé wrote:
> > On 18/10/22 08:28, Markus Armbruster wrote:
> >> The has_FOO for pointer-valued FOO are redundant, except for arrays.
> >> They are also a nuisance to work with.  Recent commit "qapi: Start to
> >> elide redundant has_FOO in generated C" provided the means to elide
> >> them step by step.  This is the step for qapi/tpm.json.
> >>
> >> Said commit explains the transformation in more detail.  The invariant
> >> violations mentioned there do not occur here.
> >>
> >> Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> >> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
> >> ---
> >>   backends/tpm/tpm_passthrough.c | 2 --
> >>   monitor/hmp-cmds.c             | 8 ++++----
> >>   scripts/qapi/schema.py         | 1 -
> >>   3 files changed, 4 insertions(+), 7 deletions(-)
> >
> >> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> >> index 8f8bd93df1..378f5b083d 100644
> >> --- a/monitor/hmp-cmds.c
> >> +++ b/monitor/hmp-cmds.c
> >> @@ -885,10 +885,10 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)
> >>           case TPM_TYPE_PASSTHROUGH:
> >>               tpo = ti->options->u.passthrough.data;
> >>               monitor_printf(mon, "%s%s%s%s",
> >> -                           tpo->has_path ? ",path=" : "",
> >> -                           tpo->has_path ? tpo->path : "",
> >> -                           tpo->has_cancel_path ? ",cancel-path=" : "",
> >> -                           tpo->has_cancel_path ? tpo->cancel_path : "");
> >> +                           tpo->path ? ",path=" : "",
> >> +                           tpo->path ?: "",
> >> +                           tpo->cancel_path ? ",cancel-path=" : "",
> >> +                           tpo->cancel_path ?: "");
> >
> > Or simply:
> >
> >              monitor_printf(mon, "%s%s",
> >                             tpo->path ? ",path=" : "",
> >                             tpo->cancel_path ? ",cancel-path=" : "");
> >
>
> this would never print any path...

I need more coffee... =) Trying to KISS:

    if (tpo->path) {
        monitor_printf(mon, ",path=%s", tpo->path);
    }
    if (tpo->cancel_path) {
        monitor_printf(mon, ",cancel-path=%s", tpo->cancel_path);
    }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]