qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [[RFC]PATCH:hw/sd:sd_init()] hw/sd : modified the sd_in


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [[RFC]PATCH:hw/sd:sd_init()] hw/sd : modified the sd_init() function
Date: Mon, 27 Mar 2017 12:13:09 +0100
User-agent: Mutt/1.8.0 (2017-02-23)

On Mon, Mar 27, 2017 at 04:01:02PM +0530, Tejaswini wrote:
> From: Tejaswini Poluri <address@hidden>

Please shorten the subject line: "[PATCH] hw/sd: simplify sd_init() prototype"

> @@ -573,16 +573,19 @@ SDState *sd_init(BlockBackend *blk, bool is_spi)
>      qdev_prop_set_drive(dev, "drive", blk, &err);
>      if (err) {
>          error_report("sd_init failed: %s", error_get_pretty(err));
> -        return NULL;
> +        return -1;
>      }
>      qdev_prop_set_bit(dev, "spi", is_spi);
>      object_property_set_bool(obj, true, "realized", &err);
>      if (err) {
>          error_report("sd_init failed: %s", error_get_pretty(err));
> -        return NULL;
> +        return -1;
>      }
> -
> -    return SD_CARD(dev);
> +    sd_state = SD_CARD(dev);

The caller will not see the new value of sd_state.  In C arguments are
passed by value.  That means they are local variables inside the
function and do not affect the caller.

I have CCed Paolo Bonzini, who posted this task.  Maybe he can explain
what he meant by "Include SDState by value instead of allocating it in
sd_init (hw/sd/)".

> +    if (!sd_state) {
> +             return -1;
> +     }

QEMU use 4 space indentation.  Please do not use tabs.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]