qemu-patch-raspberry4/hw/mem
Markus Armbruster dcfe480544 error: Avoid unnecessary error_propagate() after error_setg()
Replace

    error_setg(&err, ...);
    error_propagate(errp, err);

by

    error_setg(errp, ...);

Related pattern:

    if (...) {
        error_setg(&err, ...);
        goto out;
    }
    ...
 out:
    error_propagate(errp, err);
    return;

When all paths to label out are that way, replace by

    if (...) {
        error_setg(errp, ...);
        return;
    }

and delete the label along with the error_propagate().

When we have at most one other path that actually needs to propagate,
and maybe one at the end that where propagation is unnecessary, e.g.

    foo(..., &err);
    if (err) {
        goto out;
    }
    ...
    bar(..., &err);
 out:
    error_propagate(errp, err);
    return;

move the error_propagate() to where it's needed, like

    if (...) {
        foo(..., &err);
        error_propagate(errp, err);
        return;
    }
    ...
    bar(..., errp);
    return;

and transform the error_setg() as above.

In some places, the transformation results in obviously unnecessary
error_propagate().  The next few commits will eliminate them.

Bonus: the elimination of gotos will make later patches in this series
easier to review.

Candidates for conversion tracked down with this Coccinelle script:

    @@
    identifier err, errp;
    expression list args;
    @@
    -    error_setg(&err, args);
    +    error_setg(errp, args);
         ... when != err
         error_propagate(errp, err);

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-34-armbru@redhat.com>
2020-07-10 15:18:08 +02:00
..
Kconfig hw/arm/virt: Add nvdimm hot-plug infrastructure 2020-05-04 10:25:02 -04:00
Makefile.objs memory-device: simplify Makefile.objs conditions 2019-10-22 09:38:42 +02:00
memory-device.c memory-device: Fix memory pre-plug error API violations 2019-12-18 08:36:15 +01:00
nvdimm.c error: Avoid unnecessary error_propagate() after error_setg() 2020-07-10 15:18:08 +02:00
pc-dimm.c error: Avoid unnecessary error_propagate() after error_setg() 2020-07-10 15:18:08 +02:00
trace-events trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00