error: error_free(NULL) is safe, drop unnecessary conditionals

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20251119130855.105479-5-armbru@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
This commit is contained in:
Markus Armbruster
2025-11-19 14:08:54 +01:00
parent cfd5d4eafb
commit a4cda04107
5 changed files with 6 additions and 17 deletions

View File

@@ -62,9 +62,7 @@ static int acpi_pcihp_get_bsel(PCIBus *bus)
&local_err); &local_err);
if (local_err || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { if (local_err || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
if (local_err) {
error_free(local_err); error_free(local_err);
}
return -1; return -1;
} else { } else {
return bsel; return bsel;

View File

@@ -932,9 +932,7 @@ static void qio_channel_websock_finalize(Object *obj)
if (ioc->io_tag) { if (ioc->io_tag) {
g_source_remove(ioc->io_tag); g_source_remove(ioc->io_tag);
} }
if (ioc->io_err) {
error_free(ioc->io_err); error_free(ioc->io_err);
}
object_unref(OBJECT(ioc->master)); object_unref(OBJECT(ioc->master));
} }

View File

@@ -91,9 +91,7 @@ static void qio_task_free(QIOTask *task)
if (task->destroyResult) { if (task->destroyResult) {
task->destroyResult(task->result); task->destroyResult(task->result);
} }
if (task->err) {
error_free(task->err); error_free(task->err);
}
object_unref(task->source); object_unref(task->source);
qemu_mutex_unlock(&task->thread_lock); qemu_mutex_unlock(&task->thread_lock);

View File

@@ -1568,11 +1568,9 @@ bool migrate_has_error(MigrationState *s)
static void migrate_error_free(MigrationState *s) static void migrate_error_free(MigrationState *s)
{ {
QEMU_LOCK_GUARD(&s->error_mutex); QEMU_LOCK_GUARD(&s->error_mutex);
if (s->error) {
error_free(s->error); error_free(s->error);
s->error = NULL; s->error = NULL;
} }
}
static void migration_connect_error_propagate(MigrationState *s, Error *error) static void migration_connect_error_propagate(MigrationState *s, Error *error)
{ {

View File

@@ -875,10 +875,7 @@ static void check_parse(MachineState *ms, const SMPConfiguration *config,
config_str, expect_err, output_topo_str); config_str, expect_err, output_topo_str);
end: end:
if (err != NULL) {
error_free(err); error_free(err);
}
abort(); abort();
} }