Signed-off-by: Rafael Fonseca <r4f4rfs@xxxxxxxxx> --- src/conf/network_conf.c | 24 ++++++------------------ src/conf/network_conf.h | 12 +++++++++--- src/network/bridge_driver.c | 2 +- tests/networkxml2xmltest.c | 3 +-- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index dc64ce6959..e8491d0724 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -77,35 +77,23 @@ VIR_ENUM_IMPL(virNetworkDHCPLeaseTimeUnit, "hours", ); -static virClassPtr virNetworkXMLOptionClass; +G_DEFINE_TYPE(virNetworkXMLOption, vir_network_xml_option, G_TYPE_OBJECT); static void -virNetworkXMLOptionDispose(void *obj G_GNUC_UNUSED) +vir_network_xml_option_init(virNetworkXMLOption *xmlopt G_GNUC_UNUSED) { - return; } -static int -virNetworkXMLOnceInit(void) +static void +vir_network_xml_option_class_init(virNetworkXMLOptionClass *klass G_GNUC_UNUSED) { - if (!VIR_CLASS_NEW(virNetworkXMLOption, virClassForObject())) - return -1; - - return 0; } -VIR_ONCE_GLOBAL_INIT(virNetworkXML); - virNetworkXMLOptionPtr virNetworkXMLOptionNew(virXMLNamespacePtr xmlns) { - virNetworkXMLOptionPtr xmlopt; - - if (virNetworkXMLInitialize() < 0) - return NULL; - - if (!(xmlopt = virObjectNew(virNetworkXMLOptionClass))) - return NULL; + virNetworkXMLOptionPtr xmlopt = + VIR_NETWORK_XML_OPTION(g_object_new(VIR_TYPE_NETWORK_XML_OPTION, NULL)); if (xmlns) xmlopt->ns = *xmlns; diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index f2dc388ef0..e32339e777 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -33,17 +33,23 @@ #include "device_conf.h" #include "virbitmap.h" #include "networkcommon_conf.h" -#include "virobject.h" #include "virmacmap.h" #include "virenum.h" #include "virxml.h" +#include <glib-object.h> struct _virNetworkXMLOption { - virObject parent; + GObject parent; virXMLNamespace ns; }; -typedef struct _virNetworkXMLOption virNetworkXMLOption; + +#define VIR_TYPE_NETWORK_XML_OPTION vir_network_xml_option_get_type() +G_DECLARE_FINAL_TYPE(virNetworkXMLOption, + vir_network_xml_option, + VIR, + NETWORK_XML_OPTION, + GObject); typedef virNetworkXMLOption *virNetworkXMLOptionPtr; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 3c110a53fc..98f9b6c604 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -891,7 +891,7 @@ networkStateCleanup(void) return -1; virObjectUnref(network_driver->networkEventState); - virObjectUnref(network_driver->xmlopt); + g_clear_object(&network_driver->xmlopt); /* free inactive networks */ virObjectUnref(network_driver->networks); diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c index 700744785a..dc691330e6 100644 --- a/tests/networkxml2xmltest.c +++ b/tests/networkxml2xmltest.c @@ -30,7 +30,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, int ret; testCompareNetXML2XMLResult result = TEST_COMPARE_NET_XML2XML_RESULT_SUCCESS; virNetworkDefPtr dev = NULL; - virNetworkXMLOptionPtr xmlopt = NULL; + g_autoptr(virNetworkXMLOption) xmlopt = NULL; if (!(xmlopt = networkDnsmasqCreateXMLConf())) goto cleanup; @@ -72,7 +72,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, VIR_FREE(actual); virNetworkDefFree(dev); - virObjectUnref(xmlopt); return ret; } -- 2.26.2