aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2021-02-02 15:49:56 +0300
committerEric Blake <eblake@redhat.com>2021-03-08 16:04:46 -0600
commit1184b411016bce7590723170aa6b5984518707ec (patch)
tree2660819bdf1156bbf47b3794fcf6ee91b40f3f9b /block
parent15ce94a68ca6730466c565c3d29971aab3087bf1 (diff)
block/qcow2: refactor qcow2_update_options_prepare error paths
Keep setting ret close to setting errp and don't merge different error paths into one. This way it's more obvious that we don't return error without setting errp. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Message-Id: <20210202124956.63146-15-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/qcow2.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index a1dee95dea..0db1227ac9 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1158,6 +1158,10 @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
}
qdict_put_str(encryptopts, "format", "qcow");
r->crypto_opts = block_crypto_open_opts_init(encryptopts, errp);
+ if (!r->crypto_opts) {
+ ret = -EINVAL;
+ goto fail;
+ }
break;
case QCOW_CRYPT_LUKS:
@@ -1170,14 +1174,15 @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
}
qdict_put_str(encryptopts, "format", "luks");
r->crypto_opts = block_crypto_open_opts_init(encryptopts, errp);
+ if (!r->crypto_opts) {
+ ret = -EINVAL;
+ goto fail;
+ }
break;
default:
error_setg(errp, "Unsupported encryption method %d",
s->crypt_method_header);
- break;
- }
- if (s->crypt_method_header != QCOW_CRYPT_NONE && !r->crypto_opts) {
ret = -EINVAL;
goto fail;
}