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 <stef...@linux.vnet.ibm.com>
Signed-off-by: Markus Armbruster <arm...@redhat.com>
Reviewed-by: Stefan Berger <stef...@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=" : "");


Reply via email to