[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v5 096/126] VHDX: introduce ERRP_AUTO_PROPAGATE
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[RFC v5 096/126] VHDX: introduce ERRP_AUTO_PROPAGATE |
Date: |
Fri, 11 Oct 2019 19:05:22 +0300 |
If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call). Fix such cases.
If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
&error_fatel, this means that we don't break error_abort
(we'll abort on error_set, not on error_propagate)
This commit (together with its neighbors) was generated by
for f in $(git grep -l errp \*.[ch]); do \
spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
--macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;
then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
...
goto out;
...
out:
}
patterns, with "out:" at function end.
then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
(auto-msg was a file with this commit message)
Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.
Reported-by: Kevin Wolf <address@hidden>
Reported-by: Greg Kurz <address@hidden>
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
block/vhdx-log.c | 1 +
block/vhdx.c | 22 +++++++++-------------
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index fdd3a7adc3..176e03327b 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -748,6 +748,7 @@ exit:
int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState *s, bool *flushed,
Error **errp)
{
+ ERRP_AUTO_PROPAGATE();
int ret = 0;
VHDXHeader *hdr;
VHDXLogSequence logs = { 0 };
diff --git a/block/vhdx.c b/block/vhdx.c
index 6a09d0a55c..e3ca23214c 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -898,11 +898,11 @@ static void vhdx_close(BlockDriverState *bs)
static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
+ ERRP_AUTO_PROPAGATE();
BDRVVHDXState *s = bs->opaque;
int ret = 0;
uint32_t i;
uint64_t signature;
- Error *local_err = NULL;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
false, errp);
@@ -931,9 +931,8 @@ static int vhdx_open(BlockDriverState *bs, QDict *options,
int flags,
* header update */
vhdx_guid_generate(&s->session_guid);
- vhdx_parse_header(bs, s, &local_err);
- if (local_err != NULL) {
- error_propagate(errp, local_err);
+ vhdx_parse_header(bs, s, errp);
+ if (*errp) {
ret = -EINVAL;
goto fail;
}
@@ -1007,9 +1006,8 @@ static int vhdx_open(BlockDriverState *bs, QDict
*options, int flags,
error_setg(&s->migration_blocker, "The vhdx format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
- ret = migrate_add_blocker(s->migration_blocker, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ ret = migrate_add_blocker(s->migration_blocker, errp);
+ if (*errp) {
error_free(s->migration_blocker);
goto fail;
}
@@ -1966,11 +1964,11 @@ static int coroutine_fn vhdx_co_create_opts(const char
*filename,
QemuOpts *opts,
Error **errp)
{
+ ERRP_AUTO_PROPAGATE();
BlockdevCreateOptions *create_options = NULL;
QDict *qdict;
Visitor *v;
BlockDriverState *bs = NULL;
- Error *local_err = NULL;
int ret;
static const QDictRenames opt_renames[] = {
@@ -1989,9 +1987,8 @@ static int coroutine_fn vhdx_co_create_opts(const char
*filename,
}
/* Create and open the file (protocol layer) */
- ret = bdrv_create_file(filename, opts, &local_err);
+ ret = bdrv_create_file(filename, opts, errp);
if (ret < 0) {
- error_propagate(errp, local_err);
goto fail;
}
@@ -2012,11 +2009,10 @@ static int coroutine_fn vhdx_co_create_opts(const char
*filename,
goto fail;
}
- visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+ visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
visit_free(v);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (*errp) {
ret = -EINVAL;
goto fail;
}
--
2.21.0
- [RFC v5 084/126] SLIRP: introduce ERRP_AUTO_PROPAGATE, (continued)
- [RFC v5 084/126] SLIRP: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 086/126] TPM: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 056/126] virtio-ccw: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 060/126] megasas: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 030/126] kvm: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 068/126] scsi: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 052/126] vhost: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 085/126] Tracing: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 096/126] VHDX: introduce ERRP_AUTO_PROPAGATE,
Vladimir Sementsov-Ogievskiy <=
- [RFC v5 097/126] VDI: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 081/126] qga: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 065/126] XIVE: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 095/126] Sheepdog: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 033/126] ARM Machines: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 089/126] I/O Channels: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 091/126] colo: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 090/126] Sockets: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 088/126] Cryptography: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 094/126] RBD: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11