qapi chardev: 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/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> Message-Id: <20221104160712.3005652-12-armbru@redhat.com>
This commit is contained in:
parent
54fde4ff06
commit
8de69efab1
@ -45,7 +45,7 @@ static void qmp_chardev_open_file(Chardev *chr,
|
|||||||
DWORD accessmode;
|
DWORD accessmode;
|
||||||
DWORD flags;
|
DWORD flags;
|
||||||
|
|
||||||
if (file->has_in) {
|
if (file->in) {
|
||||||
error_setg(errp, "input file not supported");
|
error_setg(errp, "input file not supported");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ static void qmp_chardev_open_file(Chardev *chr,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->has_in) {
|
if (file->in) {
|
||||||
flags = O_RDONLY;
|
flags = O_RDONLY;
|
||||||
in = qmp_chardev_open_file_source(file->in, flags, errp);
|
in = qmp_chardev_open_file_source(file->in, flags, errp);
|
||||||
if (in < 0) {
|
if (in < 0) {
|
||||||
|
@ -1251,7 +1251,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
|
|||||||
"'fd' address type");
|
"'fd' address type");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (sock->has_tls_creds &&
|
if (sock->tls_creds &&
|
||||||
!(sock->has_server && sock->server)) {
|
!(sock->has_server && sock->server)) {
|
||||||
error_setg(errp,
|
error_setg(errp,
|
||||||
"'tls_creds' option is incompatible with "
|
"'tls_creds' option is incompatible with "
|
||||||
@ -1261,7 +1261,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_TYPE_UNIX:
|
case SOCKET_ADDRESS_TYPE_UNIX:
|
||||||
if (sock->has_tls_creds) {
|
if (sock->tls_creds) {
|
||||||
error_setg(errp,
|
error_setg(errp,
|
||||||
"'tls_creds' option is incompatible with "
|
"'tls_creds' option is incompatible with "
|
||||||
"'unix' address type");
|
"'unix' address type");
|
||||||
@ -1273,7 +1273,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_TYPE_VSOCK:
|
case SOCKET_ADDRESS_TYPE_VSOCK:
|
||||||
if (sock->has_tls_creds) {
|
if (sock->tls_creds) {
|
||||||
error_setg(errp,
|
error_setg(errp,
|
||||||
"'tls_creds' option is incompatible with "
|
"'tls_creds' option is incompatible with "
|
||||||
"'vsock' address type");
|
"'vsock' address type");
|
||||||
@ -1284,7 +1284,7 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
|
|||||||
break;
|
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");
|
error_setg(errp, "'tls_authz' option requires 'tls_creds' option");
|
||||||
return false;
|
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->wait = qemu_opt_get_bool(opts, "wait", true);
|
||||||
sock->has_reconnect = qemu_opt_find(opts, "reconnect");
|
sock->has_reconnect = qemu_opt_find(opts, "reconnect");
|
||||||
sock->reconnect = qemu_opt_get_number(opts, "reconnect", 0);
|
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->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"));
|
sock->tls_authz = g_strdup(qemu_opt_get(opts, "tls-authz"));
|
||||||
|
|
||||||
addr = g_new0(SocketAddressLegacy, 1);
|
addr = g_new0(SocketAddressLegacy, 1);
|
||||||
|
@ -178,7 +178,6 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend,
|
|||||||
udp->remote = addr;
|
udp->remote = addr;
|
||||||
|
|
||||||
if (has_local) {
|
if (has_local) {
|
||||||
udp->has_local = true;
|
|
||||||
addr = g_new0(SocketAddressLegacy, 1);
|
addr = g_new0(SocketAddressLegacy, 1);
|
||||||
addr->type = SOCKET_ADDRESS_TYPE_INET;
|
addr->type = SOCKET_ADDRESS_TYPE_INET;
|
||||||
addr->u.inet.data = g_new(InetSocketAddress, 1);
|
addr->u.inet.data = g_new(InetSocketAddress, 1);
|
||||||
|
@ -240,7 +240,7 @@ static void qemu_char_open(Chardev *chr, ChardevBackend *backend,
|
|||||||
/* Any ChardevCommon member would work */
|
/* Any ChardevCommon member would work */
|
||||||
ChardevCommon *common = backend ? backend->u.null.data : NULL;
|
ChardevCommon *common = backend ? backend->u.null.data : NULL;
|
||||||
|
|
||||||
if (common && common->has_logfile) {
|
if (common && common->logfile) {
|
||||||
int flags = O_WRONLY;
|
int flags = O_WRONLY;
|
||||||
if (common->has_logappend &&
|
if (common->has_logappend &&
|
||||||
common->logappend) {
|
common->logappend) {
|
||||||
@ -496,9 +496,7 @@ void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend)
|
|||||||
{
|
{
|
||||||
const char *logfile = qemu_opt_get(opts, "logfile");
|
const char *logfile = qemu_opt_get(opts, "logfile");
|
||||||
|
|
||||||
backend->has_logfile = logfile != NULL;
|
|
||||||
backend->logfile = g_strdup(logfile);
|
backend->logfile = g_strdup(logfile);
|
||||||
|
|
||||||
backend->has_logappend = true;
|
backend->has_logappend = true;
|
||||||
backend->logappend = qemu_opt_get_bool(opts, "logappend", false);
|
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);
|
ret = g_new0(ChardevReturn, 1);
|
||||||
if (CHARDEV_IS_PTY(chr)) {
|
if (CHARDEV_IS_PTY(chr)) {
|
||||||
ret->pty = g_strdup(chr->filename + 4);
|
ret->pty = g_strdup(chr->filename + 4);
|
||||||
ret->has_pty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -1160,7 +1157,6 @@ ChardevReturn *qmp_chardev_change(const char *id, ChardevBackend *backend,
|
|||||||
ret = g_new0(ChardevReturn, 1);
|
ret = g_new0(ChardevReturn, 1);
|
||||||
if (CHARDEV_IS_PTY(chr_new)) {
|
if (CHARDEV_IS_PTY(chr_new)) {
|
||||||
ret->pty = g_strdup(chr_new->filename + 4);
|
ret->pty = g_strdup(chr_new->filename + 4);
|
||||||
ret->has_pty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -759,7 +759,6 @@ class QAPISchemaObjectTypeMember(QAPISchemaMember):
|
|||||||
assert self.type
|
assert self.type
|
||||||
# Temporary hack to support dropping the has_FOO in reviewable chunks
|
# Temporary hack to support dropping the has_FOO in reviewable chunks
|
||||||
opt_out = [
|
opt_out = [
|
||||||
'qapi/char.json',
|
|
||||||
'qapi/crypto.json',
|
'qapi/crypto.json',
|
||||||
'qapi/dump.json',
|
'qapi/dump.json',
|
||||||
'qapi/job.json',
|
'qapi/job.json',
|
||||||
|
@ -1212,7 +1212,6 @@ static void char_file_fifo_test(void)
|
|||||||
char *fifo = g_build_filename(tmp_path, "fifo", NULL);
|
char *fifo = g_build_filename(tmp_path, "fifo", NULL);
|
||||||
char *out = g_build_filename(tmp_path, "out", NULL);
|
char *out = g_build_filename(tmp_path, "out", NULL);
|
||||||
ChardevFile file = { .in = fifo,
|
ChardevFile file = { .in = fifo,
|
||||||
.has_in = true,
|
|
||||||
.out = out };
|
.out = out };
|
||||||
ChardevBackend backend = { .type = CHARDEV_BACKEND_KIND_FILE,
|
ChardevBackend backend = { .type = CHARDEV_BACKEND_KIND_FILE,
|
||||||
.u.file.data = &file };
|
.u.file.data = &file };
|
||||||
|
Loading…
Reference in New Issue
Block a user