qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v7 05/28] bootindex: rework add_boot_device_path


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH v7 05/28] bootindex: rework add_boot_device_path function
Date: Fri, 5 Sep 2014 15:15:33 -0300
User-agent: Mutt/1.5.23 (2014-03-12)

On Fri, Sep 05, 2014 at 04:37:13PM +0800, address@hidden wrote:
[...]
> +static void del_original_boot_device(DeviceState *dev, const char *suffix)
> +{
> +    FWBootEntry *i;
> +
> +    if (dev == NULL) {
> +        return;
> +    }
> +
> +    QTAILQ_FOREACH(i, &fw_boot_order, link) {
> +        if (suffix) {
> +            if (i->dev == dev && !strcmp(i->suffix, suffix)) {
> +                QTAILQ_REMOVE(&fw_boot_order, i, link);
> +                g_free(i->suffix);
> +                g_free(i);
> +
> +                break;
> +            }
> +        } else { /* host-usb and scsi devices do not have a suffix */
> +            if (i->dev == dev) {
> +                QTAILQ_REMOVE(&fw_boot_order, i, link);
> +                g_free(i);
> +
> +                break;
> +            }
> +        }

g_free() and g_strcmp0() accept NULL as arguments, so you can replace
those 16 lines with:

    if (i->dev == dev && !g_strcmp0(i->suffix, suffix))) {
        QTAILQ_REMOVE(&fw_boot_order, i, link);
        g_free(i->suffix);
        g_free(i);
        break;
    }

-- 
Eduardo



reply via email to

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