On Mon, Jul 25, 2016 at 10:08 AM, Christophe Fergeau
<cfergeau(a)redhat.com> wrote:
On Fri, Jul 22, 2016 at 01:43:35PM +0100, Zeeshan Ali (Khattak)
wrote:
> +gboolean gvir_config_domain_hostdev_pci_get_rom_bar(GVirConfigDomainHostdevPci
*hostdev)
> +{
> + xmlNodePtr hostdev_node;
> + xmlNodePtr rom_node;
> + const gchar *bar_str;
> +
> + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_HOSTDEV_PCI(hostdev), FALSE);
> +
> + hostdev_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(hostdev));
> + g_return_val_if_fail(hostdev_node != NULL, FALSE);
> +
> + rom_node = gvir_config_xml_get_element(hostdev_node, "rom", NULL);
> + if (!rom_node || !(rom_node->children))
> + /* When containing rom node is missing, default value is TRUE for newer Qemu
*/
> + return TRUE;
> +
> + bar_str = gvir_config_xml_get_attribute_content(rom_node, "bar");
> + return (g_strcmp0(bar_str, "on"));
> +}
Still the same question as
https://www.redhat.com/archives/libvir-list/2016-July/msg00644.html
Can't it become:
gboolean gvir_config_domain_hostdev_pci_get_rom_bar(GVirConfigDomainHostdevPci *hostdev)
{
const gchar *bar_str;
g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_HOSTDEV_PCI(hostdev), FALSE);
bar_str = gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(hostdev),
"rom", "bar");
return (g_strcmp0(bar_str, "on") == 0);
}
Ah, I thought you were only talking of simplifying the if/return block.
--
Regards,
Zeeshan Ali (Khattak)