diff --git a/cfg.mk b/cfg.mk index c7721103e67090474e9d9ad5ad36360fa50e5305..b5f853bcb8c47dc6750ee96bd66b2624fa57ab52 100644 --- a/cfg.mk +++ b/cfg.mk @@ -992,7 +992,7 @@ sc_prohibit_system_error_with_vir_err: # functions. There's a corresponding exclude to allow usage within tests, # docs, examples, tools, src/libvirt-*.c, and include/libvirt/libvirt-*.h sc_prohibit_virXXXFree: - @prohibit='\bvirDomainFree\b' \ + @prohibit='\bvir(Domain|Network)Free\b' \ exclude='sc_prohibit_virXXXFree' \ halt='avoid using 'virXXXFree', use 'virObjectUnref' instead' \ $(_sc_search_regexp) @@ -1186,4 +1186,4 @@ exclude_file_name_regexp--sc_prohibit_devname = \ ^(tools/virsh.pod|cfg.mk|docs/.*)$$ exclude_file_name_regexp--sc_prohibit_virXXXFree = \ - ^(docs/|tests/|examples/|tools/|cfg.mk|src/libvirt_public.syms|include/libvirt/libvirt-domain.h|src/libvirt-(domain|qemu).c$$) + ^(docs/|tests/|examples/|tools/|cfg.mk|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network).h|src/libvirt-(domain|qemu|network).c$$) diff --git a/daemon/remote.c b/daemon/remote.c index 00b3e21c7d7e0736751b1c4bba44fa668fdee1ef..edae335252266f2135ad2ae8347ac2ea6e235e5b 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -4790,7 +4790,7 @@ remoteDispatchConnectListAllNetworks(virNetServerPtr server ATTRIBUTE_UNUSED, virNetMessageSaveError(rerr); if (nets && nnets > 0) { for (i = 0; i < nnets; i++) - virNetworkFree(nets[i]); + virObjectUnref(nets[i]); VIR_FREE(nets); } return rv; @@ -5816,8 +5816,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server ATTRIBUTE_UN VIR_FREE(callback); if (rv < 0) virNetMessageSaveError(rerr); - if (net) - virNetworkFree(net); + virObjectUnref(net); virMutexUnlock(&priv->lock); return rv; } @@ -6202,7 +6201,7 @@ remoteDispatchNetworkGetDHCPLeases(virNetServerPtr server ATTRIBUTE_UNUSED, virNetworkDHCPLeaseFree(leases[i]); VIR_FREE(leases); } - virNetworkFree(net); + virObjectUnref(net); return rv; } diff --git a/src/conf/network_event.c b/src/conf/network_event.c index 991591ad09afc4b0a67d9a32c6953977b8943c6a..862394022de6aa9a6d6a73f0f8d1a446ca525450 100644 --- a/src/conf/network_event.c +++ b/src/conf/network_event.c @@ -119,7 +119,7 @@ virNetworkEventDispatchDefaultFunc(virConnectPtr conn, VIR_WARN("Unexpected event ID %d", event->eventID); cleanup: - virNetworkFree(net); + virObjectUnref(net); } diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index e296ffc0c4ff2673e5064b46cf98daaa72226800..0555b917964f99616c5174e9962ec3ce1b74fbf6 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1058,7 +1058,6 @@ libxlMakeNic(virDomainDefPtr def, char *brname = NULL; virNetworkPtr network; virConnectPtr conn; - virErrorPtr errobj; if (!(conn = virConnectOpen("xen:///system"))) return -1; @@ -1078,11 +1077,7 @@ libxlMakeNic(virDomainDefPtr def, VIR_FREE(brname); - /* Preserve any previous failure */ - errobj = virSaveLastError(); - virNetworkFree(network); - virSetError(errobj); - virFreeError(errobj); + virObjectUnref(network); virObjectUnref(conn); if (fail) return -1; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 93db1ee450b691ca2fc4d2b753a9765a27e5bbd0..97caee35b5cc7879dfe0ff0c9724c32525d5f6df 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4178,19 +4178,13 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn, virNetworkPtr network; char *brname = NULL; bool fail = false; - virErrorPtr errobj; if (!(network = virNetworkLookupByName(conn, net->data.network.name))) goto cleanup; if (!(brname = virNetworkGetBridgeName(network))) fail = true; - /* Make sure any above failure is preserved */ - errobj = virSaveLastError(); - virNetworkFree(network); - virSetError(errobj); - virFreeError(errobj); - + virObjectUnref(network); if (fail) goto cleanup; diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 9208f0235095324200ed91c844c97e2bd84b9785..de574a9b689c2e2da74b0c7125ccd889587aa14a 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -386,7 +386,6 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn, virNetworkPtr network; char *brname = NULL; bool fail = false; - virErrorPtr errobj; if (!(network = virNetworkLookupByName(conn, net->data.network.name))) @@ -394,12 +393,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn, if (!(brname = virNetworkGetBridgeName(network))) fail = true; - /* Make sure any above failure is preserved */ - errobj = virSaveLastError(); - virNetworkFree(network); - virSetError(errobj); - virFreeError(errobj); - + virObjectUnref(network); if (fail) goto cleanup; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4ed650648312e1dd12b8c3d3389d634105ff772e..18313235038d83714427c0dca45fc031a45448e5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -298,7 +298,6 @@ qemuNetworkIfaceConnect(virDomainDefPtr def, if (actualType == VIR_DOMAIN_NET_TYPE_NETWORK) { bool fail = false; - virErrorPtr errobj; virNetworkPtr network = virNetworkLookupByName(conn, net->data.network.name); if (!network) @@ -307,12 +306,7 @@ qemuNetworkIfaceConnect(virDomainDefPtr def, if (!(brname = virNetworkGetBridgeName(network))) fail = true; - /* Make sure any above failure is preserved */ - errobj = virSaveLastError(); - virNetworkFree(network); - virSetError(errobj); - virFreeError(errobj); - + virObjectUnref(network); if (fail) return ret; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ff0eaf8016df8d22cb7f0451a6b09d5b820a7234..9467d7d937e7001e1c298bbae49dd96feae17f07 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1763,7 +1763,6 @@ qemuDomainNetGetBridgeName(virConnectPtr conn, virDomainNetDefPtr net) if (VIR_STRDUP(brname, tmpbr) < 0) goto cleanup; } else if (actualType == VIR_DOMAIN_NET_TYPE_NETWORK) { - virErrorPtr errobj; virNetworkPtr network; if (!(network = virNetworkLookupByName(conn, net->data.network.name))) { @@ -1774,12 +1773,7 @@ qemuDomainNetGetBridgeName(virConnectPtr conn, virDomainNetDefPtr net) } brname = virNetworkGetBridgeName(network); - /* Make sure any above failure is preserved */ - errobj = virSaveLastError(); - virNetworkFree(network); - virSetError(errobj); - virFreeError(errobj); - + virObjectUnref(network); } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("Interface type %d has no bridge name"), diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 48e2e25192737d31e8bd9a8302cc8b5b025a30c3..c23a087f53f00b32250832e6d26d0d4f42589a2b 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -3063,8 +3063,7 @@ remoteConnectListAllNetworks(virConnectPtr conn, cleanup: if (tmp_nets) { for (i = 0; i < ret.nets.nets_len; i++) - if (tmp_nets[i]) - virNetworkFree(tmp_nets[i]); + virObjectUnref(tmp_nets[i]); VIR_FREE(tmp_nets); } @@ -5529,7 +5528,7 @@ remoteNetworkBuildEventLifecycle(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, event = virNetworkEventLifecycleNew(net->name, net->uuid, msg->event, msg->detail); - virNetworkFree(net); + virObjectUnref(net); remoteEventQueue(priv, event, msg->callbackID); } diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 9dcd4ae373034c5f8d676e27d81753e7cea4a1c4..7a5d62bf3a3498bdd7d839e2bb09aba92ea903f0 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -213,7 +213,7 @@ umlBuildCommandLineNet(virConnectPtr conn, goto error; } bridge = virNetworkGetBridgeName(network); - virNetworkFree(network); + virObjectUnref(network); if (bridge == NULL) goto error; diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 29c6c342636cb382dd684c9bc08cdf8515e04827..7f4ec891231490c7dbc7c72bcd7593f1ca10ffd4 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -1245,7 +1245,7 @@ xenFormatNet(virConnectPtr conn, return -1; } bridge = virNetworkGetBridgeName(network); - virNetworkFree(network); + virObjectUnref(network); if (!bridge) { virReportError(VIR_ERR_INTERNAL_ERROR, _("network %s is not active"), diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index a667814c84e234cff3e6298d3dda3aac0e707437..d8783e93d4a6ce5bb64c0991147cfe9988c4aa1b 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -1915,7 +1915,7 @@ xenFormatSxprNet(virConnectPtr conn, } bridge = virNetworkGetBridgeName(network); - virNetworkFree(network); + virObjectUnref(network); if (!bridge) { virReportError(VIR_ERR_INTERNAL_ERROR, _("network %s is not active"),