[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);
}
- [PATCH v2 08/28] qapi block: Elide redundant has_FOO in generated C, (continued)
- [PATCH v2 08/28] qapi block: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/18
- [PATCH v2 15/28] qapi misc: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/18
- [PATCH v2 05/28] qapi tests: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/18
- [PATCH v2 23/28] qapi tpm: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/18
- [PATCH v2 04/28] qapi: Start to elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/18
- [PATCH v2 18/28] qapi qdev qom: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/18
- [PATCH v2 20/28] qapi rocker: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/18
- [PATCH v2 19/28] qapi replay: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/18
- [PATCH v2 11/28] qapi dump: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/18
- [PATCH v2 21/28] qapi run-state: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/18