aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-01-30 15:07:28 +0100
committerLuiz Capitulino <lcapitulino@redhat.com>2014-02-17 11:57:23 -0500
commit84d18f065fb041a1c0d78d20320d740ae0673c8a (patch)
treec43dbfdadc21d4fff0f173f9413396cd314927f9 /util
parentff9ec34de8f6a37bd29ac72c0c4c94bd5d43d7b0 (diff)
Use error_is_set() only when necessary
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. Dumb it down to obvious. Gets rid of several dozen Coverity false positives. Note that the obvious form is already used in many places. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/qemu-config.c16
-rw-r--r--util/qemu-option.c22
2 files changed, 19 insertions, 19 deletions
diff --git a/util/qemu-config.c b/util/qemu-config.c
index 9298f55ecf..797df71569 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -31,7 +31,7 @@ QemuOptsList *qemu_find_opts(const char *group)
Error *local_err = NULL;
ret = find_list(vm_config_groups, group, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_report("%s", error_get_pretty(local_err));
error_free(local_err);
}
@@ -295,7 +295,7 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname)
if (sscanf(line, "[%63s \"%63[^\"]\"]", group, id) == 2) {
/* group with id */
list = find_list(lists, group, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_report("%s", error_get_pretty(local_err));
error_free(local_err);
goto out;
@@ -306,7 +306,7 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname)
if (sscanf(line, "[%63[^]]]", group) == 1) {
/* group without id */
list = find_list(lists, group, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_report("%s", error_get_pretty(local_err));
error_free(local_err);
goto out;
@@ -376,13 +376,13 @@ static void config_parse_qdict_section(QDict *options, QemuOptsList *opts,
}
subopts = qemu_opts_create(opts, NULL, 0, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_propagate(errp, local_err);
goto out;
}
qemu_opts_absorb_qdict(subopts, subqdict, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_propagate(errp, local_err);
goto out;
}
@@ -416,13 +416,13 @@ static void config_parse_qdict_section(QDict *options, QemuOptsList *opts,
opt_name = g_strdup_printf("%s.%u", opts->name, i++);
subopts = qemu_opts_create(opts, opt_name, 1, &local_err);
g_free(opt_name);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_propagate(errp, local_err);
goto out;
}
qemu_opts_absorb_qdict(subopts, section, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_propagate(errp, local_err);
qemu_opts_del(subopts);
goto out;
@@ -450,7 +450,7 @@ void qemu_config_parse_qdict(QDict *options, QemuOptsList **lists,
for (i = 0; lists[i]; i++) {
config_parse_qdict_section(options, lists[i], &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_propagate(errp, local_err);
return;
}
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 668e5d919f..fd76cd2ada 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -246,7 +246,7 @@ int set_option_parameter(QEMUOptionParameter *list, const char *name,
switch (list->type) {
case OPT_FLAG:
parse_option_bool(name, value, &flag, &local_err);
- if (!error_is_set(&local_err)) {
+ if (!local_err) {
list->value.n = flag;
}
break;
@@ -269,7 +269,7 @@ int set_option_parameter(QEMUOptionParameter *list, const char *name,
return -1;
}
- if (error_is_set(&local_err)) {
+ if (local_err) {
qerror_report_err(local_err);
error_free(local_err);
return -1;
@@ -640,7 +640,7 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,
opt->desc = desc;
opt->str = g_strdup(value);
qemu_opt_parse(opt, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_propagate(errp, local_err);
qemu_opt_del(opt);
}
@@ -651,7 +651,7 @@ int qemu_opt_set(QemuOpts *opts, const char *name, const char *value)
Error *local_err = NULL;
opt_set(opts, name, value, false, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
qerror_report_err(local_err);
error_free(local_err);
return -1;
@@ -812,7 +812,7 @@ int qemu_opts_set(QemuOptsList *list, const char *id,
Error *local_err = NULL;
opts = qemu_opts_create(list, id, 1, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
qerror_report_err(local_err);
error_free(local_err);
return -1;
@@ -897,7 +897,7 @@ static int opts_do_parse(QemuOpts *opts, const char *params,
if (strcmp(option, "id") != 0) {
/* store and parse */
opt_set(opts, option, value, prepend, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
qerror_report_err(local_err);
error_free(local_err);
return -1;
@@ -945,7 +945,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
assert(!defaults || list->merge_lists);
opts = qemu_opts_create(list, id, !defaults, &local_err);
if (opts == NULL) {
- if (error_is_set(&local_err)) {
+ if (local_err) {
qerror_report_err(local_err);
error_free(local_err);
}
@@ -1034,7 +1034,7 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
opts = qemu_opts_create(list, qdict_get_try_str(qdict, "id"), 1,
&local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_propagate(errp, local_err);
return NULL;
}
@@ -1044,7 +1044,7 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
state.errp = &local_err;
state.opts = opts;
qdict_iter(qdict, qemu_opts_from_qdict_1, &state);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_propagate(errp, local_err);
qemu_opts_del(opts);
return NULL;
@@ -1075,7 +1075,7 @@ void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp)
if (find_desc_by_name(opts->list->desc, entry->key)) {
qemu_opts_from_qdict_1(entry->key, entry->value, &state);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_propagate(errp, local_err);
return;
} else {
@@ -1129,7 +1129,7 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
}
qemu_opt_parse(opt, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_propagate(errp, local_err);
return;
}