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>
}
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:
}
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;
}