On Fri, 11 Oct 2019 19:04:14 +0300 Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> wrote:
> 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 s/fatel/fatal/ :) > (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. I think you missed one of those... > > 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 <kw...@redhat.com> > Reported-by: Greg Kurz <gr...@kaod.org> > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> > --- > hw/intc/s390_flic_kvm.c | 9 ++++----- > hw/s390x/3270-ccw.c | 13 ++++++------- > hw/s390x/css-bridge.c | 7 +++---- > hw/s390x/css.c | 7 +++---- > hw/s390x/s390-skeys.c | 7 +++---- > hw/s390x/s390-virtio-ccw.c | 11 +++++------ > hw/s390x/sclp.c | 15 ++++++--------- > hw/s390x/tod-kvm.c | 14 ++++++-------- > hw/vfio/ccw.c | 24 +++++++++++------------- > target/s390x/cpu.c | 26 ++++++++++++-------------- > 10 files changed, 59 insertions(+), 74 deletions(-) > > diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c > index cedccba8a9..5550cecef8 100644 > --- a/hw/intc/s390_flic_kvm.c > +++ b/hw/intc/s390_flic_kvm.c > @@ -578,14 +578,14 @@ typedef struct KVMS390FLICStateClass { > > static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) > { > + ERRP_AUTO_PROPAGATE(); > KVMS390FLICState *flic_state = KVM_S390_FLIC(dev); > struct kvm_create_device cd = {0}; > struct kvm_device_attr test_attr = {0}; > int ret; > - Error *errp_local = NULL; > > - KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, &errp_local); > - if (errp_local) { > + KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, errp); > + if (*errp) { > goto fail; > } > flic_state->fd = -1; > @@ -593,7 +593,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error > **errp) > cd.type = KVM_DEV_TYPE_FLIC; > ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd); > if (ret < 0) { > - error_setg_errno(&errp_local, errno, "Creating the KVM device > failed"); > + error_setg_errno(errp, errno, "Creating the KVM device failed"); > trace_flic_create_device(errno); > goto fail; > } > @@ -605,7 +605,6 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error > **errp) > KVM_HAS_DEVICE_ATTR, test_attr); > return; > fail: > - error_propagate(errp, errp_local); ...namely, here. (You probably did not compile on a s390x, so this file was not built.) > } > > static void kvm_s390_flic_reset(DeviceState *dev) The rest of the transformations look sane.