From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: jsnow@redhat.com, eblake@redhat.com, michael.roth@amd.com,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v3 11/30] qapi chardev: Elide redundant has_FOO in generated C
Date: Fri, 4 Nov 2022 17:06:53 +0100 [thread overview]
Message-ID: <20221104160712.3005652-12-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/char.json.
Said commit explains the transformation in more detail. The invariant
violations mentioned there do not occur here.
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
chardev/char-file.c | 4 ++--
chardev/char-socket.c | 10 ++++------
chardev/char-udp.c | 1 -
chardev/char.c | 6 +-----
tests/unit/test-char.c | 1 -
scripts/qapi/schema.py | 1 -
6 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/chardev/char-file.c b/chardev/char-file.c
index 2fd80707e5..3a7b9caf6f 100644
--- a/chardev/char-file.c
+++ b/chardev/char-file.c
@@ -45,7 +45,7 @@ static void qmp_chardev_open_file(Chardev *chr,
DWORD accessmode;
DWORD flags;
- if (file->has_in) {
+ if (file->in) {
error_setg(errp, "input file not supported");
return;
}
@@ -83,7 +83,7 @@ static void qmp_chardev_open_file(Chardev *chr,
return;
}
- if (file->has_in) {
+ if (file->in) {
flags = O_RDONLY;
in = qmp_chardev_open_file_source(file->in, flags, errp);
if (in < 0) {
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 879564aa8a..29ffe5075e 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -1251,7 +1251,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
"'fd' address type");
return false;
}
- if (sock->has_tls_creds &&
+ if (sock->tls_creds &&
!(sock->has_server && sock->server)) {
error_setg(errp,
"'tls_creds' option is incompatible with "
@@ -1261,7 +1261,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
break;
case SOCKET_ADDRESS_TYPE_UNIX:
- if (sock->has_tls_creds) {
+ if (sock->tls_creds) {
error_setg(errp,
"'tls_creds' option is incompatible with "
"'unix' address type");
@@ -1273,7 +1273,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
break;
case SOCKET_ADDRESS_TYPE_VSOCK:
- if (sock->has_tls_creds) {
+ if (sock->tls_creds) {
error_setg(errp,
"'tls_creds' option is incompatible with "
"'vsock' address type");
@@ -1284,7 +1284,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
break;
}
- if (sock->has_tls_authz && !sock->has_tls_creds) {
+ if (sock->tls_authz && !sock->tls_creds) {
error_setg(errp, "'tls_authz' option requires 'tls_creds' option");
return false;
}
@@ -1465,9 +1465,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
sock->wait = qemu_opt_get_bool(opts, "wait", true);
sock->has_reconnect = qemu_opt_find(opts, "reconnect");
sock->reconnect = qemu_opt_get_number(opts, "reconnect", 0);
- sock->has_tls_creds = qemu_opt_get(opts, "tls-creds");
sock->tls_creds = g_strdup(qemu_opt_get(opts, "tls-creds"));
- sock->has_tls_authz = qemu_opt_get(opts, "tls-authz");
sock->tls_authz = g_strdup(qemu_opt_get(opts, "tls-authz"));
addr = g_new0(SocketAddressLegacy, 1);
diff --git a/chardev/char-udp.c b/chardev/char-udp.c
index 6756e69924..3d9a2d5e77 100644
--- a/chardev/char-udp.c
+++ b/chardev/char-udp.c
@@ -178,7 +178,6 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend,
udp->remote = addr;
if (has_local) {
- udp->has_local = true;
addr = g_new0(SocketAddressLegacy, 1);
addr->type = SOCKET_ADDRESS_TYPE_INET;
addr->u.inet.data = g_new(InetSocketAddress, 1);
diff --git a/chardev/char.c b/chardev/char.c
index b005df3ccf..4c5de16402 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -240,7 +240,7 @@ static void qemu_char_open(Chardev *chr, ChardevBackend *backend,
/* Any ChardevCommon member would work */
ChardevCommon *common = backend ? backend->u.null.data : NULL;
- if (common && common->has_logfile) {
+ if (common && common->logfile) {
int flags = O_WRONLY;
if (common->has_logappend &&
common->logappend) {
@@ -496,9 +496,7 @@ void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend)
{
const char *logfile = qemu_opt_get(opts, "logfile");
- backend->has_logfile = logfile != NULL;
backend->logfile = g_strdup(logfile);
-
backend->has_logappend = true;
backend->logappend = qemu_opt_get_bool(opts, "logappend", false);
}
@@ -1057,7 +1055,6 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
ret = g_new0(ChardevReturn, 1);
if (CHARDEV_IS_PTY(chr)) {
ret->pty = g_strdup(chr->filename + 4);
- ret->has_pty = true;
}
return ret;
@@ -1160,7 +1157,6 @@ ChardevReturn *qmp_chardev_change(const char *id, ChardevBackend *backend,
ret = g_new0(ChardevReturn, 1);
if (CHARDEV_IS_PTY(chr_new)) {
ret->pty = g_strdup(chr_new->filename + 4);
- ret->has_pty = true;
}
return ret;
diff --git a/tests/unit/test-char.c b/tests/unit/test-char.c
index 5b3b48ebac..649fdf64e1 100644
--- a/tests/unit/test-char.c
+++ b/tests/unit/test-char.c
@@ -1212,7 +1212,6 @@ static void char_file_fifo_test(void)
char *fifo = g_build_filename(tmp_path, "fifo", NULL);
char *out = g_build_filename(tmp_path, "out", NULL);
ChardevFile file = { .in = fifo,
- .has_in = true,
.out = out };
ChardevBackend backend = { .type = CHARDEV_BACKEND_KIND_FILE,
.u.file.data = &file };
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index a205aae1e3..707c671133 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/char.json',
'qapi/crypto.json',
'qapi/dump.json',
'qapi/job.json',
--
2.37.3
next prev parent reply other threads:[~2022-11-04 16:11 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 ` Markus Armbruster [this message]
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 ` [PATCH v3 27/30] qapi ui: " Markus Armbruster
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-12-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--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).