return ret;
}
-static int
+static void
testSELinuxMungePath(char **path)
{
- char *tmp;
-
- tmp = g_strdup_printf("%s/securityselinuxlabeldata%s", abs_builddir, *path);
+ char *tmp = g_strdup_printf("%s/securityselinuxlabeldata%s", abs_builddir, *path);
- VIR_FREE(*path);
+ g_free(*path);
*path = tmp;
- return 0;
}
static int
static virDomainDef *
testSELinuxLoadDef(const char *testname)
{
- char *xmlfile = NULL;
+ g_autofree char *xmlfile = NULL;
virDomainDef *def = NULL;
size_t i;
if (!(def = virDomainDefParseFile(xmlfile, driver.xmlopt,
NULL, 0)))
- goto cleanup;
+ return NULL;
for (i = 0; i < def->ndisks; i++) {
if (def->disks[i]->src->type != VIR_STORAGE_TYPE_FILE &&
def->disks[i]->src->type != VIR_STORAGE_TYPE_BLOCK)
continue;
- if (testSELinuxMungePath(&def->disks[i]->src->path) < 0)
- goto cleanup;
+ testSELinuxMungePath(&def->disks[i]->src->path);
}
for (i = 0; i < def->nserials; i++) {
continue;
if (def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_UNIX) {
- if (testSELinuxMungePath(&def->serials[i]->source->data.nix.path) < 0)
- goto cleanup;
+ testSELinuxMungePath(&def->serials[i]->source->data.nix.path);
} else {
- if (testSELinuxMungePath(&def->serials[i]->source->data.file.path) < 0)
- goto cleanup;
+ testSELinuxMungePath(&def->serials[i]->source->data.file.path);
}
}
- if (def->os.kernel &&
- testSELinuxMungePath(&def->os.kernel) < 0)
- goto cleanup;
- if (def->os.initrd &&
- testSELinuxMungePath(&def->os.initrd) < 0)
- goto cleanup;
+ if (def->os.kernel)
+ testSELinuxMungePath(&def->os.kernel);
+ if (def->os.initrd)
+ testSELinuxMungePath(&def->os.initrd);
- cleanup:
- VIR_FREE(xmlfile);
return def;
}