From 84d18f065fb041a1c0d78d20320d740ae0673c8a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 30 Jan 2014 15:07:28 +0100 Subject: Use error_is_set() only when necessary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Eric Blake Reviewed-by: Andreas Färber Signed-off-by: Luiz Capitulino --- qemu-img.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'qemu-img.c') diff --git a/qemu-img.c b/qemu-img.c index c989850ce7..0927b090de 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -419,7 +419,7 @@ static int img_create(int argc, char **argv) bdrv_img_create(filename, fmt, base_filename, base_fmt, options, img_size, BDRV_O_FLAGS, &local_err, quiet); - if (error_is_set(&local_err)) { + if (local_err) { error_report("%s: %s", filename, error_get_pretty(local_err)); error_free(local_err); return 1; @@ -1289,7 +1289,7 @@ static int img_convert(int argc, char **argv) bdrv_snapshot_load_tmp_by_id_or_name(bs[0], snapshot_name, &local_err); } - if (error_is_set(&local_err)) { + if (local_err) { error_report("Failed to load snapshot: %s", error_get_pretty(local_err)); error_free(local_err); @@ -1775,7 +1775,7 @@ static ImageInfoList *collect_image_info_list(const char *filename, } bdrv_query_image_info(bs, &info, &err); - if (error_is_set(&err)) { + if (err) { error_report("%s", error_get_pretty(err)); error_free(err); goto err; @@ -2184,7 +2184,7 @@ static int img_snapshot(int argc, char **argv) case SNAPSHOT_DELETE: bdrv_snapshot_delete_by_id_or_name(bs, snapshot_name, &err); - if (error_is_set(&err)) { + if (err) { error_report("Could not delete snapshot '%s': (%s)", snapshot_name, error_get_pretty(err)); error_free(err); -- cgit v1.2.3