mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
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>
This commit is contained in:
parent
ff9ec34de8
commit
84d18f065f
37 changed files with 156 additions and 156 deletions
16
block.c
16
block.c
|
@ -421,7 +421,7 @@ static void coroutine_fn bdrv_create_co_entry(void *opaque)
|
|||
assert(cco->drv);
|
||||
|
||||
ret = cco->drv->bdrv_create(cco->filename, cco->options, &local_err);
|
||||
if (error_is_set(&local_err)) {
|
||||
if (local_err) {
|
||||
error_propagate(&cco->err, local_err);
|
||||
}
|
||||
cco->ret = ret;
|
||||
|
@ -460,7 +460,7 @@ int bdrv_create(BlockDriver *drv, const char* filename,
|
|||
|
||||
ret = cco.ret;
|
||||
if (ret < 0) {
|
||||
if (error_is_set(&cco.err)) {
|
||||
if (cco.err) {
|
||||
error_propagate(errp, cco.err);
|
||||
} else {
|
||||
error_setg_errno(errp, -ret, "Could not create image");
|
||||
|
@ -486,7 +486,7 @@ int bdrv_create_file(const char* filename, QEMUOptionParameter *options,
|
|||
}
|
||||
|
||||
ret = bdrv_create(drv, filename, options, &local_err);
|
||||
if (error_is_set(&local_err)) {
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
}
|
||||
return ret;
|
||||
|
@ -909,7 +909,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
|
|||
}
|
||||
|
||||
if (ret < 0) {
|
||||
if (error_is_set(&local_err)) {
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
} else if (bs->filename[0]) {
|
||||
error_setg_errno(errp, -ret, "Could not open '%s'", bs->filename);
|
||||
|
@ -1031,7 +1031,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename,
|
|||
/* Parse the filename and open it */
|
||||
if (drv->bdrv_parse_filename && filename) {
|
||||
drv->bdrv_parse_filename(filename, options, &local_err);
|
||||
if (error_is_set(&local_err)) {
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
|
@ -1400,7 +1400,7 @@ fail:
|
|||
QDECREF(bs->options);
|
||||
QDECREF(options);
|
||||
bs->options = NULL;
|
||||
if (error_is_set(&local_err)) {
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
}
|
||||
return ret;
|
||||
|
@ -1408,7 +1408,7 @@ fail:
|
|||
close_and_fail:
|
||||
bdrv_close(bs);
|
||||
QDECREF(options);
|
||||
if (error_is_set(&local_err)) {
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
}
|
||||
return ret;
|
||||
|
@ -5338,7 +5338,7 @@ out:
|
|||
free_option_parameters(create_options);
|
||||
free_option_parameters(param);
|
||||
|
||||
if (error_is_set(&local_err)) {
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue