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: Gonglei
Subject: Re: [Qemu-devel] [PATCH v7 05/28] bootindex: rework add_boot_device_path function
Date: Mon, 8 Sep 2014 19:54:49 +0800

> Subject: Re: [Qemu-devel] [PATCH v7 05/28] bootindex: rework
> add_boot_device_path function
> 
> 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;
>     }
> 
OK. Thanks for your point!

Best regards,
-Gonglei





reply via email to

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