tests: vir: use g_autofree

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Ján Tomko 2021-09-04 22:37:31 +02:00
parent 5679b6283b
commit 526551ac0a
24 changed files with 65 additions and 140 deletions

View File

@ -174,7 +174,7 @@ testCgroupDetectMounts(const void *args)
{
int result = -1;
const struct _detectMountsData *data = args;
char *parsed = NULL;
g_autofree char *parsed = NULL;
const char *actual;
g_autoptr(virCgroup) group = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
@ -209,7 +209,6 @@ testCgroupDetectMounts(const void *args)
cleanup:
g_unsetenv("VIR_CGROUP_MOCK_FILENAME");
VIR_FREE(parsed);
return result;
}

View File

@ -70,7 +70,7 @@ static int testConfMemoryNoNewline(const void *opaque G_GNUC_UNUSED)
int ret = -1;
virConfValue *val;
unsigned long long llvalue;
char *str = NULL;
g_autofree char *str = NULL;
int uintvalue;
if (!conf)
@ -119,7 +119,6 @@ static int testConfMemoryNoNewline(const void *opaque G_GNUC_UNUSED)
ret = 0;
cleanup:
VIR_FREE(str);
return ret;
}
@ -341,7 +340,7 @@ static int testConfParseString(const void *opaque G_GNUC_UNUSED)
int ret = -1;
g_autoptr(virConf) conf = virConfReadString(srcdata, 0);
char *str = NULL;
g_autofree char *str = NULL;
if (!conf)
return -1;
@ -367,7 +366,6 @@ static int testConfParseString(const void *opaque G_GNUC_UNUSED)
ret = 0;
cleanup:
VIR_FREE(str);
return ret;
}

View File

@ -37,7 +37,7 @@ static int
testCryptoHash(const void *opaque)
{
const struct testCryptoHashData *data = opaque;
char *actual = NULL;
g_autofree char *actual = NULL;
int ret = -1;
if (virCryptoHashString(data->hash, data->input, &actual) < 0) {
@ -53,7 +53,6 @@ testCryptoHash(const void *opaque)
ret = 0;
cleanup:
VIR_FREE(actual);
return ret;
}
@ -70,11 +69,11 @@ static int
testCryptoEncrypt(const void *opaque)
{
const struct testCryptoEncryptData *data = opaque;
uint8_t *enckey = NULL;
g_autofree uint8_t *enckey = NULL;
size_t enckeylen = 32;
uint8_t *iv = NULL;
g_autofree uint8_t *iv = NULL;
size_t ivlen = 16;
uint8_t *ciphertext = NULL;
g_autofree uint8_t *ciphertext = NULL;
size_t ciphertextlen = 0;
int ret = -1;
@ -110,9 +109,6 @@ testCryptoEncrypt(const void *opaque)
ret = 0;
cleanup:
VIR_FREE(enckey);
VIR_FREE(iv);
VIR_FREE(ciphertext);
return ret;
}

View File

@ -112,14 +112,13 @@ testFileCacheLoadFile(const char *filename,
bool *outdated G_GNUC_UNUSED)
{
testFileCacheObj *obj;
char *data;
g_autofree char *data = NULL;
if (virFileReadAll(filename, 20, &data) < 0)
return NULL;
obj = testFileCacheObjNew(data);
VIR_FREE(data);
return obj;
}

View File

@ -105,7 +105,7 @@ statfs_mock(const char *mtab,
FILE *f;
struct mntent mb;
char mntbuf[1024];
char *canonPath = NULL;
g_autofree char *canonPath = NULL;
int ret = -1;
if (!(f = real_setmntent(mtab, "r"))) {
@ -158,7 +158,6 @@ statfs_mock(const char *mtab,
}
endmntent(f);
VIR_FREE(canonPath);
return ret;
}

View File

@ -104,7 +104,7 @@ testFileSanitizePath(const void *opaque)
{
const struct testFileSanitizePathData *data = opaque;
int ret = -1;
char *actual;
g_autofree char *actual = NULL;
if (!(actual = virFileSanitizePath(data->path)))
return -1;
@ -117,7 +117,6 @@ testFileSanitizePath(const void *opaque)
ret = 0;
cleanup:
VIR_FREE(actual);
return ret;
}
@ -322,7 +321,7 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED)
return EXIT_AM_SKIP;
#else
const struct testFileIsSharedFSType *data = opaque;
char *mtabFile = NULL;
g_autofree char *mtabFile = NULL;
bool actual;
int ret = -1;
@ -343,7 +342,6 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED)
ret = 0;
cleanup:
VIR_FREE(mtabFile);
g_unsetenv("LIBVIRT_MTAB");
return ret;
#endif

View File

@ -31,7 +31,7 @@ linuxTestCompareFiles(const char *cpuinfofile,
const char *outputfile)
{
int ret = -1;
char *actualData = NULL;
g_autofree char *actualData = NULL;
virNodeInfo nodeinfo;
FILE *cpuinfo;
@ -68,7 +68,6 @@ linuxTestCompareFiles(const char *cpuinfofile,
ret = 0;
fail:
VIR_FREE(actualData);
return ret;
}
@ -109,7 +108,7 @@ linuxCPUStatsCompareFiles(const char *cpustatfile,
const char *outfile)
{
int ret = -1;
char *actualData = NULL;
g_autofree char *actualData = NULL;
FILE *cpustat = NULL;
virNodeCPUStatsPtr params = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
@ -150,7 +149,6 @@ linuxCPUStatsCompareFiles(const char *cpustatfile,
fail:
VIR_FORCE_FCLOSE(cpustat);
VIR_FREE(actualData);
VIR_FREE(params);
return ret;
}
@ -165,9 +163,9 @@ static int
linuxTestHostCPU(const void *opaque)
{
int result = -1;
char *cpuinfo = NULL;
char *sysfs_prefix = NULL;
char *output = NULL;
g_autofree char *cpuinfo = NULL;
g_autofree char *sysfs_prefix = NULL;
g_autofree char *output = NULL;
struct linuxTestHostCPUData *data = (struct linuxTestHostCPUData *) opaque;
const char *archStr = virArchToString(data->arch);
@ -182,10 +180,6 @@ linuxTestHostCPU(const void *opaque)
result = linuxTestCompareFiles(cpuinfo, data->arch, output);
virFileWrapperRemovePrefix(SYSFS_SYSTEM_PATH);
VIR_FREE(cpuinfo);
VIR_FREE(output);
VIR_FREE(sysfs_prefix);
return result;
}
@ -232,8 +226,8 @@ linuxTestNodeCPUStats(const void *data)
{
const struct nodeCPUStatsData *testData = data;
int result = -1;
char *cpustatfile = NULL;
char *outfile = NULL;
g_autofree char *cpustatfile = NULL;
g_autofree g_autofree char *outfile = NULL;
cpustatfile = g_strdup_printf("%s/virhostcpudata/linux-cpustat-%s.stat",
abs_srcdir, testData->name);
@ -255,9 +249,6 @@ linuxTestNodeCPUStats(const void *data)
}
}
VIR_FREE(cpustatfile);
VIR_FREE(outfile);
return result;
}

View File

@ -210,7 +210,7 @@ testISCSIGetSession(const void *data)
{
const struct testSessionInfo *info = data;
struct testIscsiadmCbData cbData = { 0 };
char *actual_session = NULL;
g_autofree char *actual_session = NULL;
int ret = -1;
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
@ -231,7 +231,6 @@ testISCSIGetSession(const void *data)
ret = 0;
cleanup:
VIR_FREE(actual_session);
return ret;
}

View File

@ -35,7 +35,7 @@ static int
checkOutput(virBuffer *buf, const char *exp_cmd)
{
int ret = -1;
char *actual_cmd = NULL;
g_autofree char *actual_cmd = NULL;
if (!(actual_cmd = virBufferContentAndReset(buf))) {
fprintf(stderr, "cannot compare buffer to exp: %s", exp_cmd);
@ -50,7 +50,6 @@ checkOutput(virBuffer *buf, const char *exp_cmd)
ret = 0;
cleanup:
VIR_FREE(actual_cmd);
return ret;
}
@ -59,7 +58,7 @@ static int
testKModLoad(const void *args G_GNUC_UNUSED)
{
int ret = -1;
char *errbuf = NULL;
g_autofree char *errbuf = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
@ -77,7 +76,6 @@ testKModLoad(const void *args G_GNUC_UNUSED)
ret = 0;
cleanup:
VIR_FREE(errbuf);
return ret;
}
@ -86,7 +84,7 @@ static int
testKModUnload(const void *args G_GNUC_UNUSED)
{
int ret = -1;
char *errbuf = NULL;
g_autofree char *errbuf = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
@ -104,7 +102,6 @@ testKModUnload(const void *args G_GNUC_UNUSED)
ret = 0;
cleanup:
VIR_FREE(errbuf);
return ret;
}

View File

@ -39,7 +39,7 @@ testMACLookup(const void *opaque)
GSList *macs;
GSList *next;
size_t i, j;
char *file = NULL;
g_autofree char *file = NULL;
int ret = -1;
file = g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, data->file);
@ -78,7 +78,6 @@ testMACLookup(const void *opaque)
ret = 0;
cleanup:
VIR_FREE(file);
return ret;
}
@ -90,7 +89,7 @@ testMACRemove(const void *opaque)
g_autoptr(virMacMap) mgr = NULL;
GSList *macs;
size_t i;
char *file = NULL;
g_autofree char *file = NULL;
int ret = -1;
file = g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, data->file);
@ -115,7 +114,6 @@ testMACRemove(const void *opaque)
ret = 0;
cleanup:
VIR_FREE(file);
return ret;
}
@ -124,8 +122,8 @@ static int
testMACFlush(const void *opaque)
{
const struct testData *data = opaque;
char *file = NULL;
char *str = NULL;
g_autofree char *file = NULL;
g_autofree char *str = NULL;
int ret = -1;
file = g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, data->file);
@ -138,8 +136,6 @@ testMACFlush(const void *opaque)
ret = 0;
cleanup:
VIR_FREE(file);
VIR_FREE(str);
return ret;
}

View File

@ -270,10 +270,10 @@ static int testExecRestart(const void *opaque)
int ret = -1;
virNetDaemon *dmn = NULL;
const struct testExecRestartData *data = opaque;
char *infile = NULL;
char *outfile = NULL;
char *injsonstr = NULL;
char *outjsonstr = NULL;
g_autofree char *infile = NULL;
g_autofree char *outfile = NULL;
g_autofree char *injsonstr = NULL;
g_autofree char *outjsonstr = NULL;
virJSONValue *injson = NULL;
virJSONValue *outjson = NULL;
int fdclient[2] = { -1, -1 }, fdserver[2] = { -1, -1 };
@ -352,10 +352,6 @@ static int testExecRestart(const void *opaque)
VIR_TEST_DEBUG("Test should have failed");
ret = -1;
}
VIR_FREE(infile);
VIR_FREE(outfile);
VIR_FREE(injsonstr);
VIR_FREE(outjsonstr);
virJSONValueFree(injson);
virJSONValueFree(outjson);
virObjectUnref(dmn);

View File

@ -178,7 +178,7 @@ testSocketAccept(const void *opaque)
int ret = -1;
char portstr[100];
char *tmpdir = NULL;
char *path = NULL;
g_autofree char *path = NULL;
char template[] = "/tmp/libvirt_XXXXXX";
virThread th;
struct testClientData cdata = { 0 };
@ -288,7 +288,6 @@ testSocketAccept(const void *opaque)
virObjectUnref(lsock[i]);
}
VIR_FREE(lsock);
VIR_FREE(path);
if (tmpdir)
rmdir(tmpdir);
return ret;
@ -304,7 +303,7 @@ static int testSocketUNIXAddrs(const void *data G_GNUC_UNUSED)
virNetSocket *csock = NULL; /* Client socket */
int ret = -1;
char *path = NULL;
g_autofree char *path = NULL;
char *tmpdir;
char template[] = "/tmp/libvirt_XXXXXX";
@ -375,7 +374,6 @@ static int testSocketUNIXAddrs(const void *data G_GNUC_UNUSED)
ret = 0;
cleanup:
VIR_FREE(path);
virObjectUnref(lsock);
virObjectUnref(ssock);
virObjectUnref(csock);

View File

@ -36,7 +36,7 @@
static int
testCompareXMLToXMLFiles(const char *expected)
{
char *actual = NULL;
g_autofree char *actual = NULL;
int ret = -1;
g_autoptr(virNetworkPortDef) dev = NULL;
@ -51,7 +51,6 @@ testCompareXMLToXMLFiles(const char *expected)
ret = 0;
cleanup:
VIR_FREE(actual);
return ret;
}
@ -64,15 +63,12 @@ testCompareXMLToXMLHelper(const void *data)
{
const struct testInfo *info = data;
int ret = -1;
char *xml = NULL;
g_autofree char *xml = NULL;
xml = g_strdup_printf("%s/virnetworkportxml2xmldata/%s.xml", abs_srcdir,
info->name);
ret = testCompareXMLToXMLFiles(xml);
VIR_FREE(xml);
return ret;
}

View File

@ -41,13 +41,11 @@ bool
virNumaIsAvailable(void)
{
if (numa_avail < 0) {
char *sysfs_node_path = NULL;
g_autofree char *sysfs_node_path = NULL;
sysfs_node_path = g_strdup_printf("%s/node", SYSFS_SYSTEM_PATH);
numa_avail = virFileExists(sysfs_node_path);
VIR_FREE(sysfs_node_path);
}
/*
@ -165,7 +163,7 @@ int
virNumaGetNodeCPUs(int node, virBitmap **cpus)
{
int ret = -1;
char *cpulist = NULL;
g_autofree char *cpulist = NULL;
if (virFileReadValueString(&cpulist,
"%s/node/node%u/cpulist",
@ -183,6 +181,5 @@ virNumaGetNodeCPUs(int node, virBitmap **cpus)
ret = virBitmapCountBits(*cpus);
cleanup:
VIR_FREE(cpulist);
return ret;
}

View File

@ -38,7 +38,7 @@
static int
testCompareXMLToXMLFiles(const char *xml)
{
char *actual = NULL;
g_autofree char *actual = NULL;
int ret = -1;
virNWFilterBindingDef *dev = NULL;
@ -56,7 +56,6 @@ testCompareXMLToXMLFiles(const char *xml)
ret = 0;
fail:
VIR_FREE(actual);
virNWFilterBindingDefFree(dev);
return ret;
}
@ -70,15 +69,13 @@ testCompareXMLToXMLHelper(const void *data)
{
int result = -1;
const test_parms *tp = data;
char *xml = NULL;
g_autofree char *xml = NULL;
xml = g_strdup_printf("%s/virnwfilterbindingxml2xmldata/%s.xml", abs_srcdir,
tp->name);
result = testCompareXMLToXMLFiles(xml);
VIR_FREE(xml);
return result;
}

View File

@ -32,8 +32,8 @@
static int
testVirPCIDeviceCheckDriver(virPCIDevice *dev, const char *expected)
{
char *path = NULL;
char *driver = NULL;
g_autofree char *path = NULL;
g_autofree char *driver = NULL;
int ret = -1;
if (virPCIDeviceGetDriverPathAndName(dev, &path, &driver) < 0)
@ -49,8 +49,6 @@ testVirPCIDeviceCheckDriver(virPCIDevice *dev, const char *expected)
ret = 0;
cleanup:
VIR_FREE(path);
VIR_FREE(driver);
return ret;
}
@ -339,7 +337,7 @@ static int
mymain(void)
{
int ret = 0;
char *fakerootdir;
g_autofree char *fakerootdir = NULL;
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
@ -361,12 +359,11 @@ mymain(void)
struct testPCIDevData data = { \
domain, bus, slot, function, NULL \
}; \
char *label = NULL; \
g_autofree char *label = NULL; \
label = g_strdup_printf("%s(%04x:%02x:%02x.%x)", \
#fnc, domain, bus, slot, function); \
if (virTestRun(label, fnc, &data) < 0) \
ret = -1; \
VIR_FREE(label); \
} while (0)
# define DO_TEST_PCI_DRIVER(domain, bus, slot, function, driver) \
@ -374,14 +371,13 @@ mymain(void)
struct testPCIDevData data = { \
domain, bus, slot, function, driver \
}; \
char *label = NULL; \
g_autofree char *label = NULL; \
label = g_strdup_printf("PCI driver %04x:%02x:%02x.%x is %s", \
domain, bus, slot, function, \
NULLSTR(driver)); \
if (virTestRun(label, testVirPCIDeviceCheckDriverTest, \
&data) < 0) \
ret = -1; \
VIR_FREE(label); \
} while (0)
/* Changes made to individual devices are persistent and the
@ -419,8 +415,6 @@ mymain(void)
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(fakerootdir);
VIR_FREE(fakerootdir);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -18,12 +18,12 @@ static int
test_virResctrlGetUnused(const void *opaque)
{
struct virResctrlData *data = (struct virResctrlData *) opaque;
char *system_dir = NULL;
char *resctrl_dir = NULL;
g_autofree char *system_dir = NULL;
g_autofree char *resctrl_dir = NULL;
int ret = -1;
g_autoptr(virResctrlAlloc) alloc = NULL;
char *schemata_str = NULL;
char *schemata_file;
g_autofree char *schemata_str = NULL;
g_autofree char *schemata_file = NULL;
g_autoptr(virCaps) caps = NULL;
system_dir = g_strdup_printf("%s/vircaps2xmldata/linux-%s/system", abs_srcdir,
@ -65,10 +65,6 @@ test_virResctrlGetUnused(const void *opaque)
ret = 0;
cleanup:
VIR_FREE(system_dir);
VIR_FREE(resctrl_dir);
VIR_FREE(schemata_str);
VIR_FREE(schemata_file);
return ret;
}

View File

@ -36,7 +36,7 @@ static char *virscsi_prefix;
static int
test1(const void *data G_GNUC_UNUSED)
{
char *name = NULL;
g_autofree char *name = NULL;
int ret = -1;
if (!(name = virSCSIDeviceGetDevName(virscsi_prefix,
@ -48,7 +48,6 @@ test1(const void *data G_GNUC_UNUSED)
ret = 0;
cleanup:
VIR_FREE(name);
return ret;
}
@ -66,7 +65,7 @@ test2(const void *data G_GNUC_UNUSED)
bool free_dev = true;
bool free_dev1 = true;
virSCSIDevice *tmp = NULL;
char *sgname = NULL;
g_autofree char *sgname = NULL;
int ret = -1;
sgname = virSCSIDeviceGetSgName(virscsi_prefix,
@ -152,7 +151,6 @@ test2(const void *data G_GNUC_UNUSED)
ret = 0;
cleanup:
VIR_FREE(sgname);
if (free_dev)
virSCSIDeviceFree(dev);
if (free_dev1)
@ -164,8 +162,8 @@ static int
create_symlink(const char *tmpdir, const char *src_name, const char *dst_name)
{
int ret = -1;
char *src_path = NULL;
char *dst_path = NULL;
g_autofree char *src_path = NULL;
g_autofree char *dst_path = NULL;
src_path = g_strdup_printf("%s/%s", virscsi_prefix, src_name);
@ -179,9 +177,6 @@ create_symlink(const char *tmpdir, const char *src_name, const char *dst_name)
ret = 0;
cleanup:
VIR_FREE(src_path);
VIR_FREE(dst_path);
return ret;
}

View File

@ -222,7 +222,7 @@ static int
testStringReplace(const void *opaque G_GNUC_UNUSED)
{
const struct stringReplaceData *data = opaque;
char *result;
g_autofree char *result = NULL;
int ret = -1;
result = virStringReplace(data->haystack,
@ -238,7 +238,6 @@ testStringReplace(const void *opaque G_GNUC_UNUSED)
ret = 0;
cleanup:
VIR_FREE(result);
return ret;
}
@ -402,7 +401,7 @@ static int testStripIPv6Brackets(const void *args)
{
const struct testStripData *data = args;
int ret = -1;
char *res = NULL;
g_autofree char *res = NULL;
res = g_strdup(data->string);
@ -417,7 +416,6 @@ static int testStripIPv6Brackets(const void *args)
ret = 0;
cleanup:
VIR_FREE(res);
return ret;
}
@ -425,7 +423,7 @@ static int testStripControlChars(const void *args)
{
const struct testStripData *data = args;
int ret = -1;
char *res = NULL;
g_autofree char *res = NULL;
res = g_strdup(data->string);
@ -440,7 +438,6 @@ static int testStripControlChars(const void *args)
ret = 0;
cleanup:
VIR_FREE(res);
return ret;
}
@ -454,7 +451,7 @@ static int testFilterChars(const void *args)
{
const struct testFilterData *data = args;
int ret = -1;
char *res = NULL;
g_autofree char *res = NULL;
res = g_strdup(data->string);
@ -469,7 +466,6 @@ static int testFilterChars(const void *args)
ret = 0;
cleanup:
VIR_FREE(res);
return ret;
}

View File

@ -325,7 +325,7 @@ static int testCreateNetwork(const void *opaque G_GNUC_UNUSED)
static int
testGetMachineName(const void *opaque G_GNUC_UNUSED)
{
char *tmp = virSystemdGetMachineNameByPID(1234);
g_autofree char *tmp = virSystemdGetMachineNameByPID(1234);
int ret = -1;
if (!tmp) {
@ -336,7 +336,6 @@ testGetMachineName(const void *opaque G_GNUC_UNUSED)
if (STREQ(tmp, "qemu-demo"))
ret = 0;
VIR_FREE(tmp);
return ret;
}
@ -371,7 +370,7 @@ testScopeName(const void *opaque)
{
const struct testNameData *data = opaque;
int ret = -1;
char *actual = NULL;
g_autofree char *actual = NULL;
if (!(actual = virSystemdMakeScopeName(data->name, "lxc", data->legacy)))
goto cleanup;
@ -385,7 +384,6 @@ testScopeName(const void *opaque)
ret = 0;
cleanup:
VIR_FREE(actual);
return ret;
}
@ -394,7 +392,7 @@ testMachineName(const void *opaque)
{
const struct testNameData *data = opaque;
int ret = -1;
char *actual = NULL;
g_autofree char *actual = NULL;
if (!(actual = virDomainDriverGenerateMachineName("qemu", data->root,
data->id, data->name, true)))
@ -409,7 +407,6 @@ testMachineName(const void *opaque)
ret = 0;
cleanup:
VIR_FREE(actual);
return ret;
}

View File

@ -100,9 +100,9 @@ static void
checkPath(const char *path,
const char *func)
{
char *fullPath = NULL;
char *relPath = NULL;
char *crippledPath = NULL;
g_autofree char *fullPath = NULL;
g_autofree char *relPath = NULL;
g_autofree char *crippledPath = NULL;
if (!g_path_is_absolute(path))
relPath = g_strdup_printf("./%s", path);
@ -130,10 +130,6 @@ checkPath(const char *path,
printFile(path, func);
}
VIR_FREE(crippledPath);
VIR_FREE(relPath);
VIR_FREE(fullPath);
return;
}

View File

@ -49,7 +49,7 @@ static int testURIParse(const void *args)
int ret = -1;
virURI *uri = NULL;
const struct URIParseData *data = args;
char *uristr = NULL;
g_autofree char *uristr = NULL;
size_t i;
bool fail = false;
@ -134,7 +134,6 @@ static int testURIParse(const void *args)
ret = 0;
cleanup:
VIR_FREE(uristr);
virURIFree(uri);
return ret;
}

View File

@ -63,7 +63,7 @@ static char *get_fake_path(const char *real_path)
DIR *opendir(const char *name)
{
char *path;
g_autofree char *path = NULL;
DIR* ret;
init_syms();
@ -71,13 +71,12 @@ DIR *opendir(const char *name)
path = get_fake_path(name);
ret = realopendir(path);
VIR_FREE(path);
return ret;
}
int open(const char *pathname, int flags, ...)
{
char *path;
g_autofree char *path = NULL;
int ret;
va_list ap;
mode_t mode = 0;
@ -98,7 +97,5 @@ int open(const char *pathname, int flags, ...)
}
ret = realopen(path, flags, mode);
VIR_FREE(path);
return ret;
}

View File

@ -49,7 +49,7 @@ static int testDeviceFileActor(virUSBDevice *dev,
const char *path,
void *opaque G_GNUC_UNUSED)
{
char *str = NULL;
g_autofree char *str = NULL;
int ret = 0;
str = g_strdup_printf(USB_DEVFS "%03d/%03d", virUSBDeviceGetBus(dev),
@ -61,7 +61,6 @@ static int testDeviceFileActor(virUSBDevice *dev,
path, str);
ret = -1;
}
VIR_FREE(str);
return ret;
}