[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH-for-5.1 v2 04/54] hw/arm/aspeed_ast2600: Simplify use of Erro
From: |
Cédric Le Goater |
Subject: |
Re: [PATCH-for-5.1 v2 04/54] hw/arm/aspeed_ast2600: Simplify use of Error* |
Date: |
Tue, 7 Apr 2020 08:46:52 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 |
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_ast2600.c
> >>> possible moves from aspeed_soc_ast2600_init() to
> aspeed_soc_ast2600_realize() in ./hw/arm/aspeed_ast2600.c:243
>
> While reviewing we notice we don't need two different Error*,
> drop the one less used.
I think that comes from another pattern we were using at some time
which was propagating the second error in the first. Anyhow, this
is better.
Reviewed-by: Cédric Le Goater <address@hidden>
It seems that the 'return' are badly aligned ?
Thanks,
C.
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> hw/arm/aspeed_ast2600.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
> index 1a869e09b9..b08359f3ef 100644
> --- a/hw/arm/aspeed_ast2600.c
> +++ b/hw/arm/aspeed_ast2600.c
> @@ -245,7 +245,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev,
> Error **errp)
> int i;
> AspeedSoCState *s = ASPEED_SOC(dev);
> AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
> - Error *err = NULL, *local_err = NULL;
> + Error *err = NULL;
> qemu_irq irq;
>
> /* IO space */
> @@ -418,9 +418,12 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev,
> Error **errp)
> return;
> }
> object_property_set_int(OBJECT(&s->spi[i]), 1, "num-cs", &err);
> + if (err) {
> + error_propagate(errp, err);
> + return;
> + }
> object_property_set_bool(OBJECT(&s->spi[i]), true, "realized",
> - &local_err);
> - error_propagate(&err, local_err);
> + &err);
> if (err) {
> error_propagate(errp, err);
> return;
> @@ -472,9 +475,12 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev,
> Error **errp)
> qdev_set_nic_properties(DEVICE(&s->ftgmac100[i]), &nd_table[i]);
> object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed",
> &err);
> + if (err) {
> + error_propagate(errp, err);
> + return;
> + }
> object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "realized",
> - &local_err);
> - error_propagate(&err, local_err);
> + &err);
> if (err) {
> error_propagate(errp, err);
> return;
>