]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qapi tpm: Elide redundant has_FOO in generated C
authorMarkus Armbruster <armbru@redhat.com>
Fri, 4 Nov 2022 16:07:07 +0000 (17:07 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 14 Dec 2022 19:05:07 +0000 (20:05 +0100)
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>
Message-Id: <20221104160712.3005652-26-armbru@redhat.com>

backends/tpm/tpm_passthrough.c
monitor/hmp-cmds.c
scripts/qapi/schema.py

index 5a2f74db1b3825c7e2d80782e38e537c7c7138f5..179697a3a94011307ff2dc98634ddd685c2c75a9 100644 (file)
@@ -259,12 +259,10 @@ tpm_passthrough_handle_device_opts(TPMPassthruState *tpm_pt, QemuOpts *opts)
     value = qemu_opt_get(opts, "cancel-path");
     if (value) {
         tpm_pt->options->cancel_path = g_strdup(value);
-        tpm_pt->options->has_cancel_path = true;
     }
 
     value = qemu_opt_get(opts, "path");
     if (value) {
-        tpm_pt->options->has_path = true;
         tpm_pt->options->path = g_strdup(value);
     }
 
index a41f94a34ac7b1621e4af4077820014201dbae9c..3ada344d77bb1a66ec3a7714e495880ed22f7a35 100644 (file)
@@ -864,10 +864,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 ?: "");
             break;
         case TPM_TYPE_EMULATOR:
             teo = ti->options->u.emulator.data;
index 0544037e71252eccf5048101e9442cb9e9110f90..f0726af876dbc5d69cb636633db25207eed772c1 100644 (file)
@@ -759,7 +759,6 @@ class QAPISchemaObjectTypeMember(QAPISchemaMember):
         assert self.type
         # Temporary hack to support dropping the has_FOO in reviewable chunks
         opt_out = [
-            'qapi/tpm.json',
             'qapi/transaction.json',
             'qapi/ui.json',
             'qapi/virtio.json',