mirror of https://gitee.com/openkylin/libvirt.git
tests: use g_autoptr instead of virObjectUnref
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
a26df27662
commit
d66fb7ac15
|
@ -526,7 +526,7 @@ cpuTestCPUID(bool guest, const void *arg)
|
|||
g_autofree char *host = NULL;
|
||||
g_autoptr(virCPUDef) cpu = NULL;
|
||||
g_autofree char *result = NULL;
|
||||
virDomainCapsCPUModels *models = NULL;
|
||||
g_autoptr(virDomainCapsCPUModels) models = NULL;
|
||||
|
||||
hostFile = g_strdup_printf("%s/cputestdata/%s-cpuid-%s.xml", abs_srcdir,
|
||||
virArchToString(data->arch), data->host);
|
||||
|
@ -563,7 +563,6 @@ cpuTestCPUID(bool guest, const void *arg)
|
|||
ret = cpuTestCompareXML(data->arch, cpu, result);
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(models);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -728,8 +727,8 @@ cpuTestUpdateLive(const void *arg)
|
|||
g_autoptr(virCPUData) disabledData = NULL;
|
||||
g_autofree char *expectedFile = NULL;
|
||||
g_autoptr(virCPUDef) expected = NULL;
|
||||
virDomainCapsCPUModels *hvModels = NULL;
|
||||
virDomainCapsCPUModels *models = NULL;
|
||||
g_autoptr(virDomainCapsCPUModels) hvModels = NULL;
|
||||
g_autoptr(virDomainCapsCPUModels) models = NULL;
|
||||
int ret = -1;
|
||||
|
||||
cpuFile = g_strdup_printf("cpuid-%s-guest", data->host);
|
||||
|
@ -795,8 +794,6 @@ cpuTestUpdateLive(const void *arg)
|
|||
ret = cpuTestUpdateLiveCompare(data->arch, cpu, expected);
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(hvModels);
|
||||
virObjectUnref(models);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ fillQemuCaps(virDomainCaps *domCaps,
|
|||
{
|
||||
int ret = -1;
|
||||
char *path = NULL;
|
||||
virQEMUCaps *qemuCaps = NULL;
|
||||
g_autoptr(virQEMUCaps) qemuCaps = NULL;
|
||||
virDomainCapsLoader *loader = &domCaps->os.loader;
|
||||
virDomainVirtType virtType;
|
||||
|
||||
|
@ -127,7 +127,6 @@ fillQemuCaps(virDomainCaps *domCaps,
|
|||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virObjectUnref(qemuCaps);
|
||||
VIR_FREE(path);
|
||||
return ret;
|
||||
}
|
||||
|
@ -208,7 +207,7 @@ static int
|
|||
test_virDomainCapsFormat(const void *opaque)
|
||||
{
|
||||
const struct testData *data = opaque;
|
||||
virDomainCaps *domCaps = NULL;
|
||||
g_autoptr(virDomainCaps) domCaps = NULL;
|
||||
char *path = NULL;
|
||||
char *domCapsXML = NULL;
|
||||
int ret = -1;
|
||||
|
@ -256,7 +255,6 @@ test_virDomainCapsFormat(const void *opaque)
|
|||
cleanup:
|
||||
VIR_FREE(domCapsXML);
|
||||
VIR_FREE(path);
|
||||
virObjectUnref(domCaps);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf,
|
|||
virCommand *cmd = NULL;
|
||||
char *pidfile = NULL;
|
||||
dnsmasqContext *dctx = NULL;
|
||||
virNetworkXMLOption *xmlopt = NULL;
|
||||
g_autoptr(virNetworkXMLOption) xmlopt = NULL;
|
||||
|
||||
if (!(xmlopt = networkDnsmasqCreateXMLConf()))
|
||||
goto fail;
|
||||
|
@ -85,7 +85,6 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf,
|
|||
VIR_FREE(hostsfileactual);
|
||||
VIR_FREE(pidfile);
|
||||
virCommandFree(cmd);
|
||||
virObjectUnref(xmlopt);
|
||||
virNetworkObjEndAPI(&obj);
|
||||
dnsmasqContextFree(dctx);
|
||||
return ret;
|
||||
|
|
|
@ -30,7 +30,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
|
|||
int ret;
|
||||
testCompareNetXML2XMLResult result = TEST_COMPARE_NET_XML2XML_RESULT_SUCCESS;
|
||||
virNetworkDef *dev = NULL;
|
||||
virNetworkXMLOption *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;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ static int
|
|||
test_virCapsDomainDataLookupQEMU(const void *data G_GNUC_UNUSED)
|
||||
{
|
||||
int ret = 0;
|
||||
virCaps *caps = NULL;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
|
||||
if (!(caps = testQemuCapsInit())) {
|
||||
ret = -1;
|
||||
|
@ -196,7 +196,6 @@ test_virCapsDomainDataLookupQEMU(const void *data G_GNUC_UNUSED)
|
|||
CAPS_EXPECT_ERR(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_VMWARE, NULL, "pc");
|
||||
|
||||
out:
|
||||
virObjectUnref(caps);
|
||||
return ret;
|
||||
}
|
||||
#endif /* WITH_QEMU */
|
||||
|
@ -206,7 +205,7 @@ static int
|
|||
test_virCapsDomainDataLookupLXC(const void *data G_GNUC_UNUSED)
|
||||
{
|
||||
int ret = 0;
|
||||
virCaps *caps = NULL;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
|
||||
if (!(caps = testLXCCapsInit())) {
|
||||
ret = -1;
|
||||
|
@ -221,7 +220,6 @@ test_virCapsDomainDataLookupLXC(const void *data G_GNUC_UNUSED)
|
|||
VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL);
|
||||
|
||||
out:
|
||||
virObjectUnref(caps);
|
||||
return ret;
|
||||
}
|
||||
#endif /* WITH_LXC */
|
||||
|
|
|
@ -35,7 +35,7 @@ static int
|
|||
testMACLookup(const void *opaque)
|
||||
{
|
||||
const struct testData *data = opaque;
|
||||
virMacMap *mgr = NULL;
|
||||
g_autoptr(virMacMap) mgr = NULL;
|
||||
GSList *macs;
|
||||
GSList *next;
|
||||
size_t i, j;
|
||||
|
@ -79,7 +79,6 @@ testMACLookup(const void *opaque)
|
|||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(file);
|
||||
virObjectUnref(mgr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -88,7 +87,7 @@ static int
|
|||
testMACRemove(const void *opaque)
|
||||
{
|
||||
const struct testData *data = opaque;
|
||||
virMacMap *mgr = NULL;
|
||||
g_autoptr(virMacMap) mgr = NULL;
|
||||
GSList *macs;
|
||||
size_t i;
|
||||
char *file = NULL;
|
||||
|
@ -117,7 +116,6 @@ testMACRemove(const void *opaque)
|
|||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(file);
|
||||
virObjectUnref(mgr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,8 +93,8 @@ testVirPCIDeviceDetach(const void *opaque G_GNUC_UNUSED)
|
|||
int ret = -1;
|
||||
virPCIDevice *dev[] = {NULL, NULL, NULL};
|
||||
size_t i, nDev = G_N_ELEMENTS(dev);
|
||||
virPCIDeviceList *activeDevs = NULL;
|
||||
virPCIDeviceList *inactiveDevs = NULL;
|
||||
g_autoptr(virPCIDeviceList) activeDevs = NULL;
|
||||
g_autoptr(virPCIDeviceList) inactiveDevs = NULL;
|
||||
int count;
|
||||
|
||||
if (!(activeDevs = virPCIDeviceListNew()) ||
|
||||
|
@ -126,8 +126,6 @@ testVirPCIDeviceDetach(const void *opaque G_GNUC_UNUSED)
|
|||
cleanup:
|
||||
for (i = 0; i < nDev; i++)
|
||||
virPCIDeviceFree(dev[i]);
|
||||
virObjectUnref(activeDevs);
|
||||
virObjectUnref(inactiveDevs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -137,8 +135,8 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED)
|
|||
int ret = -1;
|
||||
virPCIDevice *dev[] = {NULL, NULL, NULL};
|
||||
size_t i, nDev = G_N_ELEMENTS(dev);
|
||||
virPCIDeviceList *activeDevs = NULL;
|
||||
virPCIDeviceList *inactiveDevs = NULL;
|
||||
g_autoptr(virPCIDeviceList) activeDevs = NULL;
|
||||
g_autoptr(virPCIDeviceList) inactiveDevs = NULL;
|
||||
int count;
|
||||
|
||||
if (!(activeDevs = virPCIDeviceListNew()) ||
|
||||
|
@ -164,8 +162,6 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED)
|
|||
cleanup:
|
||||
for (i = 0; i < nDev; i++)
|
||||
virPCIDeviceFree(dev[i]);
|
||||
virObjectUnref(activeDevs);
|
||||
virObjectUnref(inactiveDevs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -175,8 +171,8 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED)
|
|||
int ret = -1;
|
||||
virPCIDevice *dev[] = {NULL, NULL, NULL};
|
||||
size_t i, nDev = G_N_ELEMENTS(dev);
|
||||
virPCIDeviceList *activeDevs = NULL;
|
||||
virPCIDeviceList *inactiveDevs = NULL;
|
||||
g_autoptr(virPCIDeviceList) activeDevs = NULL;
|
||||
g_autoptr(virPCIDeviceList) inactiveDevs = NULL;
|
||||
int count;
|
||||
|
||||
if (!(activeDevs = virPCIDeviceListNew()) ||
|
||||
|
@ -213,8 +209,6 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED)
|
|||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virObjectUnref(activeDevs);
|
||||
virObjectUnref(inactiveDevs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@ test_virResctrlGetUnused(const void *opaque)
|
|||
char *system_dir = NULL;
|
||||
char *resctrl_dir = NULL;
|
||||
int ret = -1;
|
||||
virResctrlAlloc *alloc = NULL;
|
||||
g_autoptr(virResctrlAlloc) alloc = NULL;
|
||||
char *schemata_str = NULL;
|
||||
char *schemata_file;
|
||||
virCaps *caps = NULL;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
|
||||
system_dir = g_strdup_printf("%s/vircaps2xmldata/linux-%s/system", abs_srcdir,
|
||||
data->filename);
|
||||
|
@ -65,8 +65,6 @@ test_virResctrlGetUnused(const void *opaque)
|
|||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(alloc);
|
||||
VIR_FREE(system_dir);
|
||||
VIR_FREE(resctrl_dir);
|
||||
VIR_FREE(schemata_str);
|
||||
|
|
|
@ -60,7 +60,7 @@ test1(const void *data G_GNUC_UNUSED)
|
|||
static int
|
||||
test2(const void *data G_GNUC_UNUSED)
|
||||
{
|
||||
virSCSIDeviceList *list = NULL;
|
||||
g_autoptr(virSCSIDeviceList) list = NULL;
|
||||
virSCSIDevice *dev = NULL;
|
||||
virSCSIDevice *dev1 = NULL;
|
||||
bool free_dev = true;
|
||||
|
@ -157,7 +157,6 @@ test2(const void *data G_GNUC_UNUSED)
|
|||
virSCSIDeviceFree(dev);
|
||||
if (free_dev1)
|
||||
virSCSIDeviceFree(dev1);
|
||||
virObjectUnref(list);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ static int testDeviceFind(const void *opaque)
|
|||
const struct findTestInfo *info = opaque;
|
||||
int ret = -1;
|
||||
virUSBDevice *dev = NULL;
|
||||
virUSBDeviceList *devs = NULL;
|
||||
g_autoptr(virUSBDeviceList) devs = NULL;
|
||||
int rv = 0;
|
||||
size_t i, ndevs = 0;
|
||||
|
||||
|
@ -123,7 +123,6 @@ static int testDeviceFind(const void *opaque)
|
|||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(devs);
|
||||
virUSBDeviceFree(dev);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ testCompareParseXML(const char *xlcfg, const char *xml, bool replaceVars)
|
|||
{
|
||||
char *gotxlcfgData = NULL;
|
||||
g_autoptr(virConf) conf = NULL;
|
||||
virConnectPtr conn = NULL;
|
||||
g_autoptr(virConnect) conn = NULL;
|
||||
int wrote = 4096;
|
||||
int ret = -1;
|
||||
virDomainDef *def = NULL;
|
||||
|
@ -111,7 +111,6 @@ testCompareParseXML(const char *xlcfg, const char *xml, bool replaceVars)
|
|||
VIR_FREE(replacedXML);
|
||||
VIR_FREE(gotxlcfgData);
|
||||
virDomainDefFree(def);
|
||||
virObjectUnref(conn);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -127,7 +126,7 @@ testCompareFormatXML(const char *xlcfg, const char *xml, bool replaceVars)
|
|||
char *gotxml = NULL;
|
||||
g_autoptr(virConf) conf = NULL;
|
||||
int ret = -1;
|
||||
virConnectPtr conn;
|
||||
g_autoptr(virConnect) conn = NULL;
|
||||
virDomainDef *def = NULL;
|
||||
char *replacedXML = NULL;
|
||||
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
|
||||
|
@ -166,7 +165,6 @@ testCompareFormatXML(const char *xlcfg, const char *xml, bool replaceVars)
|
|||
VIR_FREE(xlcfgData);
|
||||
VIR_FREE(gotxml);
|
||||
virDomainDefFree(def);
|
||||
virObjectUnref(conn);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ testCompareParseXML(const char *xmcfg, const char *xml)
|
|||
char *gotxmcfgData = NULL;
|
||||
g_autoptr(virConf) conf = NULL;
|
||||
int ret = -1;
|
||||
virConnectPtr conn = NULL;
|
||||
g_autoptr(virConnect) conn = NULL;
|
||||
int wrote = 4096;
|
||||
virDomainDef *def = NULL;
|
||||
|
||||
|
@ -75,7 +75,6 @@ testCompareParseXML(const char *xmcfg, const char *xml)
|
|||
fail:
|
||||
VIR_FREE(gotxmcfgData);
|
||||
virDomainDefFree(def);
|
||||
virObjectUnref(conn);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue