On 4/6/20 7:46 PM, Philippe Mathieu-Daudé wrote:
> Coccinelle reported:
> 
>   $ spatch ... --timeout 60 --sp-file \
>     scripts/coccinelle/simplify-init-realize-error_propagate.cocci
>   HANDLING: ./hw/arm/aspeed_soc.c
>   >>> possible moves from aspeed_soc_init() to aspeed_soc_realize() in 
> ./hw/arm/aspeed_soc.c:231
> 
> Move the calls using &error_fatal which don't depend of input
> updated before realize() to init().
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>

Reviewed-by: Cédric Le Goater <c...@kaod.org>

Thanks,

C. 

> ---
>  hw/arm/aspeed_soc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
> index 696c7fda14..debd7c8faa 100644
> --- a/hw/arm/aspeed_soc.c
> +++ b/hw/arm/aspeed_soc.c
> @@ -183,6 +183,7 @@ static void aspeed_soc_init(Object *obj)
>          snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, 
> socname);
>          sysbus_init_child_obj(obj, "spi[*]", OBJECT(&s->spi[i]),
>                                sizeof(s->spi[i]), typename);
> +        object_property_set_int(OBJECT(&s->spi[i]), 1, "num-cs", 
> &error_abort);
>      }
>  
>      for (i = 0; i < sc->ehcis_num; i++) {
> @@ -360,10 +361,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error 
> **errp)
>  
>      /* SPI */
>      for (i = 0; i < sc->spis_num; i++) {
> -        object_property_set_int(OBJECT(&s->spi[i]), 1, "num-cs", &err);
> -        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized",
> -                                 &local_err);
> -        error_propagate(&err, local_err);
> +        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
>          if (err) {
>              error_propagate(errp, err);
>              return;
> 


Reply via email to