Clean up some calls to ignore Error objects the right way

Receiving the error in a local variable only to free it is less clear
(and also less efficient) than passing NULL.  Clean up.

Cc: Daniel P. Berrange <berrange@redhat.com>
Cc: Jerome Forissier <jerome@forissier.org>
CC: Greg Kurz <groug@kaod.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <20200630090351.1247703-4-armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Markus Armbruster 2020-06-30 11:03:28 +02:00
parent 5a79d10c95
commit 9261ef5e32
5 changed files with 7 additions and 16 deletions

View File

@ -817,22 +817,20 @@ static void tcp_chr_tls_init(Chardev *chr)
{
SocketChardev *s = SOCKET_CHARDEV(chr);
QIOChannelTLS *tioc;
Error *err = NULL;
gchar *name;
if (s->is_listen) {
tioc = qio_channel_tls_new_server(
s->ioc, s->tls_creds,
s->tls_authz,
&err);
NULL);
} else {
tioc = qio_channel_tls_new_client(
s->ioc, s->tls_creds,
s->addr->u.inet.host,
&err);
NULL);
}
if (tioc == NULL) {
error_free(err);
tcp_chr_disconnect(chr);
return;
}

View File

@ -1399,7 +1399,6 @@ static void coroutine_fn v9fs_attach(void *opaque)
size_t offset = 7;
V9fsQID qid;
ssize_t err;
Error *local_err = NULL;
v9fs_string_init(&uname);
v9fs_string_init(&aname);
@ -1437,9 +1436,8 @@ static void coroutine_fn v9fs_attach(void *opaque)
error_setg(&s->migration_blocker,
"Migration is disabled when VirtFS export path '%s' is mounted in the guest using mount_tag '%s'",
s->ctx.fs_root ? s->ctx.fs_root : "NULL", s->tag);
err = migrate_add_blocker(s->migration_blocker, &local_err);
if (local_err) {
error_free(local_err);
err = migrate_add_blocker(s->migration_blocker, NULL);
if (err < 0) {
error_free(s->migration_blocker);
s->migration_blocker = NULL;
clunk_fid(s, fid);

View File

@ -217,11 +217,9 @@ static bool cpu_type_valid(const char *cpu)
static void create_kaslr_seed(VirtMachineState *vms, const char *node)
{
Error *err = NULL;
uint64_t seed;
if (qemu_guest_getrandom(&seed, sizeof(seed), &err)) {
error_free(err);
if (qemu_guest_getrandom(&seed, sizeof(seed), NULL)) {
return;
}
qemu_fdt_setprop_u64(vms->fdt, node, "kaslr-seed", seed);

View File

@ -1163,16 +1163,14 @@ static void rtas_ibm_configure_connector(PowerPCCPU *cpu,
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
if (!drc->fdt) {
Error *local_err = NULL;
void *fdt;
int fdt_size;
fdt = create_device_tree(&fdt_size);
if (drck->dt_populate(drc, spapr, fdt, &drc->fdt_start_offset,
&local_err)) {
NULL)) {
g_free(fdt);
error_free(local_err);
rc = SPAPR_DR_CC_RESPONSE_ERROR;
goto out;
}

View File

@ -458,9 +458,8 @@ static VncServerInfo2List *qmp_query_server_entry(QIOChannelSocket *ioc,
Error *err = NULL;
SocketAddress *addr;
addr = qio_channel_socket_get_local_address(ioc, &err);
addr = qio_channel_socket_get_local_address(ioc, NULL);
if (!addr) {
error_free(err);
return prev;
}