Use error_is_set() only when necessary (again)

error_is_set(&var) is the same as var != NULL, but it takes
whole-program analysis to figure that out.  Unnecessarily hard for
optimizers, static checkers, and human readers.  Commit 84d18f0 dumbed
it down to obvious, but a few more have crept in since, and
documentation was overlooked.  Dumb these down, too.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Markus Armbruster 2014-04-25 16:50:31 +02:00 committed by Stefan Hajnoczi
parent a28315ebaf
commit 0fb6395c0c
6 changed files with 12 additions and 12 deletions

View File

@ -864,7 +864,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
node_name = qdict_get_try_str(options, "node-name");
bdrv_assign_node_name(bs, node_name, &local_err);
if (error_is_set(&local_err)) {
if (local_err) {
error_propagate(errp, local_err);
return -EINVAL;
}

View File

@ -680,7 +680,7 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
mirror_start_job(bs, base, speed, 0, 0,
on_error, on_error, cb, opaque, &local_err,
&commit_active_job_driver, false, base);
if (error_is_set(&local_err)) {
if (local_err) {
error_propagate(errp, local_err);
goto error_restore_flags;
}

View File

@ -343,7 +343,7 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (error_is_set(&local_err)) {
if (local_err) {
error_propagate(errp, local_err);
return -EINVAL;
}

View File

@ -753,7 +753,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
opts = qemu_opts_create(&quorum_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (error_is_set(&local_err)) {
if (local_err) {
ret = -EINVAL;
goto exit;
}
@ -828,7 +828,7 @@ close_exit:
g_free(opened);
exit:
/* propagate error */
if (error_is_set(&local_err)) {
if (local_err) {
error_propagate(errp, local_err);
}
QDECREF(list);

View File

@ -311,7 +311,7 @@ void hmp_hello_world(Monitor *mon, const QDict *qdict)
Error *errp = NULL;
qmp_hello_world(!!message, message, &errp);
if (error_is_set(&errp)) {
if (errp) {
monitor_printf(mon, "%s\n", error_get_pretty(errp));
error_free(errp);
return;
@ -483,7 +483,7 @@ void hmp_info_alarm_clock(Monitor *mon)
Error *errp = NULL;
clock = qmp_query_alarm_clock(&errp);
if (error_is_set(&errp)) {
if (errp) {
monitor_printf(mon, "Could not query alarm clock information\n");
error_free(errp);
return;
@ -634,7 +634,7 @@ void hmp_info_alarm_methods(Monitor *mon)
Error *errp = NULL;
method_list = qmp_query_alarm_methods(&errp);
if (error_is_set(&errp)) {
if (errp) {
monitor_printf(mon, "Could not query alarm methods\n");
error_free(errp);
return;

View File

@ -153,7 +153,7 @@ static void test_validate_union_flat(TestInputVisitorData *data,
/* TODO when generator bug is fixed, add 'integer': 41 */
visit_type_UserDefFlatUnion(v, &tmp, NULL, &errp);
g_assert(!error_is_set(&errp));
g_assert(!errp);
qapi_free_UserDefFlatUnion(tmp);
}
@ -167,7 +167,7 @@ static void test_validate_union_anon(TestInputVisitorData *data,
v = validate_test_init(data, "42");
visit_type_UserDefAnonUnion(v, &tmp, NULL, &errp);
g_assert(!error_is_set(&errp));
g_assert(!errp);
qapi_free_UserDefAnonUnion(tmp);
}
@ -240,7 +240,7 @@ static void test_validate_fail_union_flat(TestInputVisitorData *data,
v = validate_test_init(data, "{ 'string': 'c', 'integer': 41, 'boolean': true }");
visit_type_UserDefFlatUnion(v, &tmp, NULL, &errp);
g_assert(error_is_set(&errp));
g_assert(errp);
qapi_free_UserDefFlatUnion(tmp);
}
@ -254,7 +254,7 @@ static void test_validate_fail_union_anon(TestInputVisitorData *data,
v = validate_test_init(data, "3.14");
visit_type_UserDefAnonUnion(v, &tmp, NULL, &errp);
g_assert(error_is_set(&errp));
g_assert(errp);
qapi_free_UserDefAnonUnion(tmp);
}