mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
testCompareDomXML2XMLFiles: Sanitize handling of 'parse_flags'
Get rid of the extra temporary variable and set the parse and format flags based on liveness together. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6443d77239
commit
0253d145e9
@ -1045,25 +1045,24 @@ int
|
|||||||
testCompareDomXML2XMLFiles(virCaps *caps G_GNUC_UNUSED,
|
testCompareDomXML2XMLFiles(virCaps *caps G_GNUC_UNUSED,
|
||||||
virDomainXMLOption *xmlopt,
|
virDomainXMLOption *xmlopt,
|
||||||
const char *infile, const char *outfile, bool live,
|
const char *infile, const char *outfile, bool live,
|
||||||
unsigned int parseFlags,
|
unsigned int parse_flags,
|
||||||
testCompareDomXML2XMLResult expectResult)
|
testCompareDomXML2XMLResult expectResult)
|
||||||
{
|
{
|
||||||
g_autofree char *actual = NULL;
|
g_autofree char *actual = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
testCompareDomXML2XMLResult result;
|
testCompareDomXML2XMLResult result;
|
||||||
g_autoptr(virDomainDef) def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
unsigned int parse_flags = live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
|
||||||
unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE;
|
unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE;
|
||||||
|
|
||||||
parse_flags |= parseFlags;
|
|
||||||
|
|
||||||
if (!virFileExists(infile)) {
|
if (!virFileExists(infile)) {
|
||||||
VIR_TEST_DEBUG("Test input file '%s' is missing", infile);
|
VIR_TEST_DEBUG("Test input file '%s' is missing", infile);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!live)
|
if (!live) {
|
||||||
format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
|
format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
|
||||||
|
parse_flags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(def = virDomainDefParseFile(infile, xmlopt, NULL, parse_flags))) {
|
if (!(def = virDomainDefParseFile(infile, xmlopt, NULL, parse_flags))) {
|
||||||
result = TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE;
|
result = TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE;
|
||||||
|
Loading…
Reference in New Issue
Block a user