qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: jsnow@redhat.com, eblake@redhat.com, michael.roth@amd.com,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>
Subject: [PATCH v3 27/30] qapi ui: Elide redundant has_FOO in generated C
Date: Fri,  4 Nov 2022 17:07:09 +0100	[thread overview]
Message-ID: <20221104160712.3005652-28-armbru@redhat.com> (raw)
In-Reply-To: <20221104160712.3005652-1-armbru@redhat.com>

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/ui.json.

Said commit explains the transformation in more detail.  The invariant
violations mentioned there do not occur here.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
 monitor/hmp-cmds.c     | 12 ++++--------
 ui/console.c           |  4 ++--
 ui/input.c             |  4 ++--
 ui/spice-core.c        |  5 -----
 ui/vnc.c               | 10 ----------
 scripts/qapi/schema.py |  1 -
 6 files changed, 8 insertions(+), 28 deletions(-)

diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 3ada344d77..263b7762ab 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -548,11 +548,9 @@ static void hmp_info_vnc_clients(Monitor *mon, VncClientInfoList *client)
 
         hmp_info_VncBasicInfo(mon, qapi_VncClientInfo_base(cinfo), "Client");
         monitor_printf(mon, "    x509_dname: %s\n",
-                       cinfo->has_x509_dname ?
-                       cinfo->x509_dname : "none");
+                       cinfo->x509_dname ?: "none");
         monitor_printf(mon, "    sasl_username: %s\n",
-                       cinfo->has_sasl_username ?
-                       cinfo->sasl_username : "none");
+                       cinfo->sasl_username ?: "none");
 
         client = client->next;
     }
@@ -597,7 +595,7 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict)
             hmp_info_vnc_authcrypt(mon, "  ", info->auth,
                                info->has_vencrypt ? &info->vencrypt : NULL);
         }
-        if (info->has_display) {
+        if (info->display) {
             monitor_printf(mon, "  Display: %s\n", info->display);
         }
         info2l = info2l->next;
@@ -1401,7 +1399,6 @@ void hmp_set_password(Monitor *mon, const QDict *qdict)
     }
 
     if (opts.protocol == DISPLAY_PROTOCOL_VNC) {
-        opts.u.vnc.has_display = !!display;
         opts.u.vnc.display = (char *)display;
     }
 
@@ -1429,7 +1426,6 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
     }
 
     if (opts.protocol == DISPLAY_PROTOCOL_VNC) {
-        opts.u.vnc.has_display = !!display;
         opts.u.vnc.display = (char *)display;
     }
 
@@ -1714,7 +1710,7 @@ hmp_screendump(Monitor *mon, const QDict *qdict)
         goto end;
     }
 
-    qmp_screendump(filename, id != NULL, id, id != NULL, head,
+    qmp_screendump(filename, id, id != NULL, head,
                    input_format != NULL, format, &err);
 end:
     hmp_handle_error(mon, err);
diff --git a/ui/console.c b/ui/console.c
index 65c117874c..1b1d84dadc 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -407,7 +407,7 @@ static void graphic_hw_update_bh(void *con)
 
 /* Safety: coroutine-only, concurrent-coroutine safe, main thread only */
 void coroutine_fn
-qmp_screendump(const char *filename, bool has_device, const char *device,
+qmp_screendump(const char *filename, const char *device,
                bool has_head, int64_t head,
                bool has_format, ImageFormat format, Error **errp)
 {
@@ -416,7 +416,7 @@ qmp_screendump(const char *filename, bool has_device, const char *device,
     DisplaySurface *surface;
     int fd;
 
-    if (has_device) {
+    if (device) {
         con = qemu_console_lookup_by_device_name(device, has_head ? head : 0,
                                                  errp);
         if (!con) {
diff --git a/ui/input.c b/ui/input.c
index e2a90af889..8f4a87d1d7 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -124,7 +124,7 @@ qemu_input_find_handler(uint32_t mask, QemuConsole *con)
     return NULL;
 }
 
-void qmp_input_send_event(bool has_device, const char *device,
+void qmp_input_send_event(const char *device,
                           bool has_head, int64_t head,
                           InputEventList *events, Error **errp)
 {
@@ -133,7 +133,7 @@ void qmp_input_send_event(bool has_device, const char *device,
     Error *err = NULL;
 
     con = NULL;
-    if (has_device) {
+    if (device) {
         if (!has_head) {
             head = 0;
         }
diff --git a/ui/spice-core.c b/ui/spice-core.c
index c3ac20ad43..72f8f1681c 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -222,7 +222,6 @@ static void channel_event(int event, SpiceChannelEventInfo *info)
         break;
     case SPICE_CHANNEL_EVENT_INITIALIZED:
         if (auth) {
-            server->has_auth = true;
             server->auth = g_strdup(auth);
         }
         add_channel_info(client, info);
@@ -522,13 +521,9 @@ static SpiceInfo *qmp_query_spice_real(Error **errp)
     port = qemu_opt_get_number(opts, "port", 0);
     tls_port = qemu_opt_get_number(opts, "tls-port", 0);
 
-    info->has_auth = true;
     info->auth = g_strdup(auth);
-
-    info->has_host = true;
     info->host = g_strdup(addr ? addr : "*");
 
-    info->has_compiled_version = true;
     major = (SPICE_SERVER_VERSION & 0xff0000) >> 16;
     minor = (SPICE_SERVER_VERSION & 0xff00) >> 8;
     micro = SPICE_SERVER_VERSION & 0xff;
diff --git a/ui/vnc.c b/ui/vnc.c
index 88f55cbf3c..d9eacad759 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -244,7 +244,6 @@ static VncServerInfo *vnc_server_info_get(VncDisplay *vd)
     info = g_malloc0(sizeof(*info));
     vnc_init_basic_info_from_server_addr(vd->listener->sioc[0],
                                          qapi_VncServerInfo_base(info), &err);
-    info->has_auth = true;
     info->auth = g_strdup(vnc_auth_name(vd));
     if (err) {
         qapi_free_VncServerInfo(info);
@@ -263,13 +262,10 @@ static void vnc_client_cache_auth(VncState *client)
     if (client->tls) {
         client->info->x509_dname =
             qcrypto_tls_session_get_peer_name(client->tls);
-        client->info->has_x509_dname =
-            client->info->x509_dname != NULL;
     }
 #ifdef CONFIG_VNC_SASL
     if (client->sasl.conn &&
         client->sasl.username) {
-        client->info->has_sasl_username = true;
         client->info->sasl_username = g_strdup(client->sasl.username);
     }
 #endif
@@ -341,11 +337,9 @@ static VncClientInfo *qmp_query_vnc_client(const VncState *client)
 
     if (client->tls) {
         info->x509_dname = qcrypto_tls_session_get_peer_name(client->tls);
-        info->has_x509_dname = info->x509_dname != NULL;
     }
 #ifdef CONFIG_VNC_SASL
     if (client->sasl.conn && client->sasl.username) {
-        info->has_sasl_username = true;
         info->sasl_username = g_strdup(client->sasl.username);
     }
 #endif
@@ -426,11 +420,8 @@ VncInfo *qmp_query_vnc(Error **errp)
             abort();
         }
 
-        info->has_host = true;
-        info->has_service = true;
         info->has_family = true;
 
-        info->has_auth = true;
         info->auth = g_strdup(vnc_auth_name(vd));
     }
 
@@ -568,7 +559,6 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp)
         if (vd->dcl.con) {
             dev = DEVICE(object_property_get_link(OBJECT(vd->dcl.con),
                                                   "device", &error_abort));
-            info->has_display = true;
             info->display = g_strdup(dev->id);
         }
         for (i = 0; vd->listener != NULL && i < vd->listener->nsioc; i++) {
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 3673296ad8..fd18f8249b 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -759,7 +759,6 @@ def need_has(self):
         assert self.type
         # Temporary hack to support dropping the has_FOO in reviewable chunks
         opt_out = [
-            'qapi/ui.json',
             'qapi/virtio.json',
             'qga/qapi-schema.json']
         if self.info and any(self.info.fname.endswith(mod)
-- 
2.37.3



  parent reply	other threads:[~2022-11-04 16:10 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04 16:06 [PATCH v3 00/30] qapi: Elide redundant has_FOO in generated C Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 01/30] docs/devel/qapi-code-gen: Update example to match current code Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 02/30] qapi: Tidy up whitespace in generated code Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 03/30] docs/devel/qapi-code-gen: Extend example for next commit's change Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 04/30] qapi: Start to elide redundant has_FOO in generated C Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 05/30] qapi tests: Elide " Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 06/30] qapi acpi: " Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 07/30] qapi audio: " Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 08/30] blockdev: Clean up abuse of DriveBackup member format Markus Armbruster
2022-11-04 19:32   ` Eric Blake
2022-11-04 16:06 ` [PATCH v3 09/30] nbd/server: Clean up abuse of BlockExportOptionsNbd member @arg Markus Armbruster
2022-11-04 19:35   ` Eric Blake
2022-11-08 14:21   ` Vladimir Sementsov-Ogievskiy
2022-11-04 16:06 ` [PATCH v3 10/30] qapi block: Elide redundant has_FOO in generated C Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 11/30] qapi chardev: " Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 12/30] qapi crypto: " Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 13/30] qapi dump: " Markus Armbruster
2022-11-05 17:15   ` Philippe Mathieu-Daudé
2022-11-04 16:06 ` [PATCH v3 14/30] qapi job: " Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 15/30] qapi machine: " Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 16/30] qapi migration: " Markus Armbruster
2022-11-04 16:06 ` [PATCH v3 17/30] qapi misc: " Markus Armbruster
2022-11-04 16:07 ` [PATCH v3 18/30] qapi net: " Markus Armbruster
2022-11-05 17:03   ` Philippe Mathieu-Daudé
2022-11-04 16:07 ` [PATCH v3 19/30] qapi pci: " Markus Armbruster
2022-11-04 16:07 ` [PATCH v3 20/30] qapi qdev qom: " Markus Armbruster
2022-11-05 17:06   ` Philippe Mathieu-Daudé
2022-11-04 16:07 ` [PATCH v3 21/30] qapi replay: " Markus Armbruster
2022-11-04 16:07 ` [PATCH v3 22/30] qapi rocker: " Markus Armbruster
2022-11-05 17:08   ` Philippe Mathieu-Daudé
2022-11-04 16:07 ` [PATCH v3 23/30] qapi run-state: " Markus Armbruster
2022-11-04 16:07 ` [PATCH v3 24/30] qapi stats: " Markus Armbruster
2022-11-04 16:07 ` [PATCH v3 25/30] qapi tpm: " Markus Armbruster
2022-11-04 16:07 ` [PATCH v3 26/30] qapi transaction: " Markus Armbruster
2022-11-05 17:08   ` Philippe Mathieu-Daudé
2022-11-04 16:07 ` Markus Armbruster [this message]
2022-11-04 16:07 ` [PATCH v3 28/30] qapi virtio: " Markus Armbruster
2022-11-04 16:07 ` [PATCH v3 29/30] qapi qga: " Markus Armbruster
2022-11-05 17:13   ` Philippe Mathieu-Daudé
2022-11-04 16:07 ` [PATCH v3 30/30] qapi: Drop temporary logic to support conversion step by step Markus Armbruster
2022-11-04 16:15 ` [PATCH v3 00/30] qapi: Elide redundant has_FOO in generated C Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221104160712.3005652-28-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).