Received: from eggs.gnu.org ([2001:4830:134:3::10]:44024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPy3A-00058s-1Z for qemu-devel@nongnu.org; Fri, 05 Sep 2014 14:16:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPy34-0002fh-E4 for qemu-devel@nongnu.org; Fri, 05 Sep 2014 14:15:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52669) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPy34-0002fZ-6m for qemu-devel@nongnu.org; Fri, 05 Sep 2014 14:15:50 -0400 Date: Fri, 5 Sep 2014 15:15:33 -0300 From: Eduardo Habkost Message-ID: <20140905181533.GK32084@thinpad.lan.raisama.net> References: <1409906256-11368-1-git-send-email-arei.gonglei@huawei.com> <1409906256-11368-6-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1409906256-11368-6-git-send-email-arei.gonglei@huawei.com> Subject: Re: [Qemu-devel] [PATCH v7 05/28] bootindex: rework add_boot_device_path function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com Cc: chenliang88@huawei.com, weidong.huang@huawei.com, mst@redhat.com, aik@ozlabs.ru, hutao@cn.fujitsu.com, qemu-devel@nongnu.org, armbru@redhat.com, kraxel@redhat.com, akong@redhat.com, agraf@suse.de, aliguori@amazon.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, hani@linux.com, stefanha@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com, kwolf@redhat.com, peter.crosthwaite@xilinx.com, imammedo@redhat.com, afaerber@suse.de On Fri, Sep 05, 2014 at 04:37:13PM +0800, arei.gonglei@huawei.com 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