Commit 84d18f06 authored by Markus Armbruster's avatar Markus Armbruster Committed by Luiz Capitulino
Browse files

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: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarAndreas Färber <afaerber@suse.de>
Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
parent ff9ec34d
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -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);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -303,7 +303,7 @@ static int read_config(BDRVBlkdebugState *s, const char *filename,
    }

    qemu_config_parse_qdict(options, config_groups, &local_err);
    if (error_is_set(&local_err)) {
    if (local_err) {
        error_propagate(errp, local_err);
        ret = -EINVAL;
        goto fail;
@@ -393,7 +393,7 @@ static int blkdebug_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);
        ret = -EINVAL;
        goto out;
+1 −1
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ static int blkverify_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);
        ret = -EINVAL;
        goto fail;
+1 −1
Original line number Diff line number Diff line
@@ -463,7 +463,7 @@ static int curl_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) {
        qerror_report_err(local_err);
        error_free(local_err);
        goto out_noclean;
+1 −1
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options,

    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) {
        qerror_report_err(local_err);
        error_free(local_err);
        ret = -EINVAL;
Loading