diff options
author | Markus Armbruster <armbru@redhat.com> | 2022-11-04 17:06:59 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2022-12-14 20:04:47 +0100 |
commit | 9492718b7c00c0a16e2ce834752b8c200e3217d1 (patch) | |
tree | e9bcd5905b084e2655c1f0b7ce3c5c33bf5e765b /monitor | |
parent | 720a252c2651b1b701632d407d34044e844d0e31 (diff) |
qapi misc: Elide redundant has_FOO in generated C
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/misc.json.
Said commit explains the transformation in more detail. The invariant
violations mentioned there do not occur here.
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20221104160712.3005652-18-armbru@redhat.com>
Diffstat (limited to 'monitor')
-rw-r--r-- | monitor/hmp-cmds.c | 2 | ||||
-rw-r--r-- | monitor/misc.c | 19 | ||||
-rw-r--r-- | monitor/qmp-cmds.c | 6 |
3 files changed, 7 insertions, 20 deletions
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index aa71fdba11..c5c8cb593e 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -104,7 +104,7 @@ void hmp_info_name(Monitor *mon, const QDict *qdict) NameInfo *info; info = qmp_query_name(NULL); - if (info->has_name) { + if (info->name) { monitor_printf(mon, "%s\n", info->name); } qapi_free_NameInfo(info); diff --git a/monitor/misc.c b/monitor/misc.c index 78790306b1..77aa5f1650 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1132,7 +1132,7 @@ void monitor_fdsets_cleanup(void) } } -AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque, +AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, const char *opaque, Error **errp) { int fd; @@ -1145,8 +1145,7 @@ AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque, goto error; } - fdinfo = monitor_fdset_add_fd(fd, has_fdset_id, fdset_id, - has_opaque, opaque, errp); + fdinfo = monitor_fdset_add_fd(fd, has_fdset_id, fdset_id, opaque, errp); if (fdinfo) { return fdinfo; } @@ -1214,12 +1213,7 @@ FdsetInfoList *qmp_query_fdsets(Error **errp) fdsetfd_info = g_malloc0(sizeof(*fdsetfd_info)); fdsetfd_info->fd = mon_fdset_fd->fd; - if (mon_fdset_fd->opaque) { - fdsetfd_info->has_opaque = true; - fdsetfd_info->opaque = g_strdup(mon_fdset_fd->opaque); - } else { - fdsetfd_info->has_opaque = false; - } + fdsetfd_info->opaque = g_strdup(mon_fdset_fd->opaque); QAPI_LIST_PREPEND(fdset_info->fds, fdsetfd_info); } @@ -1231,8 +1225,7 @@ FdsetInfoList *qmp_query_fdsets(Error **errp) } AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, - bool has_opaque, const char *opaque, - Error **errp) + const char *opaque, Error **errp) { MonFdset *mon_fdset = NULL; MonFdsetFd *mon_fdset_fd; @@ -1300,9 +1293,7 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, mon_fdset_fd = g_malloc0(sizeof(*mon_fdset_fd)); mon_fdset_fd->fd = fd; mon_fdset_fd->removed = false; - if (has_opaque) { - mon_fdset_fd->opaque = g_strdup(opaque); - } + mon_fdset_fd->opaque = g_strdup(opaque); QLIST_INSERT_HEAD(&mon_fdset->fds, mon_fdset_fd, next); fdinfo = g_malloc0(sizeof(*fdinfo)); diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 81c8fdadf8..f8ab5dd50f 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -50,11 +50,7 @@ NameInfo *qmp_query_name(Error **errp) { NameInfo *info = g_malloc0(sizeof(*info)); - if (qemu_name) { - info->has_name = true; - info->name = g_strdup(qemu_name); - } - + info->name = g_strdup(qemu_name); return info; } |