[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH-for-5.0 07/12] hw/mips/cps: Add missing error-propagation cod
From: |
Peter Maydell |
Subject: |
Re: [PATCH-for-5.0 07/12] hw/mips/cps: Add missing error-propagation code |
Date: |
Thu, 26 Mar 2020 21:43:47 +0000 |
On Wed, 25 Mar 2020 at 19:18, Philippe Mathieu-Daudé <address@hidden> wrote:
>
> Patch created mechanically by running:
>
> $ spatch \
> --macro-file scripts/cocci-macro-file.h --include-headers \
> --sp-file
> scripts/coccinelle/object_property_missing_error_propagate.cocci \
> --keep-comments --smpl-spacing --in-place --dir hw
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> hw/mips/cps.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 52 insertions(+)
>
> /* Inter-Thread Communication Unit */
> if (itu_present) {
> sysbus_init_child_obj(OBJECT(dev), "itu", &s->itu, sizeof(s->itu),
> TYPE_MIPS_ITU);
> object_property_set_int(OBJECT(&s->itu), 16, "num-fifo", &err);
> + if (err) {
> + error_propagate(errp, err);
> + return;
> + }
> object_property_set_int(OBJECT(&s->itu), 16, "num-semaphores", &err);
> + if (err) {
> + error_propagate(errp, err);
> + return;
> + }
> object_property_set_bool(OBJECT(&s->itu), saar_present,
> "saar-present",
> &err);
> + if (err) {
> + error_propagate(errp, err);
> + return;
> + }
> if (saar_present) {
> s->itu.saar = &env->CP0_SAAR;
> }
> object_property_set_bool(OBJECT(&s->itu), true, "realized", &err);
> + if (err) {
> + error_propagate(errp, err);
> + return;
> + }
> if (err != NULL) {
> error_propagate(errp, err);
> return;
> }
I think Coccinelle has been fooled here by the slightly non-idiomatic
use of "err != NULL" in the guard and has inserted a duplicate
check...
> memory_region_add_subregion(&s->container, 0,
> sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->itu),
> 0));
> }
>
> /* Cluster Power Controller */
> sysbus_init_child_obj(OBJECT(dev), "cpc", &s->cpc, sizeof(s->cpc),
> TYPE_MIPS_CPC);
> object_property_set_int(OBJECT(&s->cpc), s->num_vp, "num-vp", &err);
> + if (err) {
> + error_propagate(errp, err);
> + return;
> + }
> object_property_set_int(OBJECT(&s->cpc), 1, "vp-start-running", &err);
> + if (err) {
> + error_propagate(errp, err);
> + return;
> + }
> object_property_set_bool(OBJECT(&s->cpc), true, "realized", &err);
> if (err != NULL) {
> error_propagate(errp, err);
> return;
> }
...but oddly it gets it right here and in a couple of other cases
in this patch.
thanks
-- PMM
- Re: [PATCH-for-5.0 02/12] hw/arm/bcm2835_peripherals: Add missing error-propagation code, (continued)
- [PATCH-for-5.0 05/12] hw/i386/x86: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/03/25
- [PATCH-for-5.0 04/12] hw/arm/stm32fx05_soc: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/03/25
- [PATCH-for-5.0 06/12] hw/dma/xilinx_axidma: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/03/25
- [PATCH-for-5.0 07/12] hw/mips/cps: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/03/25
- [PATCH-for-5.0 08/12] hw/mips/boston: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/03/25
- [PATCH-for-5.0 09/12] hw/mips/mips_malta: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/03/25
- [PATCH-for-5.0 10/12] hw/misc/macio/macio: Add missing error-propagation code, Philippe Mathieu-Daudé, 2020/03/25