mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virSecurityLabelDefParseXML: Directly assign strings into appropriate variables
'seclabel->label', 'seclabel->imagelabel' and 'seclabel->baselabel' are populated by stealing the pointer from the 'p' temporary string. Remove the extra step. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f7ff8556ad
commit
b63c70810c
@ -7874,36 +7874,32 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
if (seclabel->type == VIR_DOMAIN_SECLABEL_STATIC ||
|
if (seclabel->type == VIR_DOMAIN_SECLABEL_STATIC ||
|
||||||
(!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
|
(!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
|
||||||
seclabel->type != VIR_DOMAIN_SECLABEL_NONE)) {
|
seclabel->type != VIR_DOMAIN_SECLABEL_NONE)) {
|
||||||
p = virXPathStringLimit("string(./label[1])",
|
seclabel->label = virXPathStringLimit("string(./label[1])",
|
||||||
VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
|
VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
|
||||||
if (p == NULL) {
|
if (!seclabel->label) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("security label is missing"));
|
"%s", _("security label is missing"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
seclabel->label = g_steal_pointer(&p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only parse imagelabel, if requested live XML with relabeling */
|
/* Only parse imagelabel, if requested live XML with relabeling */
|
||||||
if (seclabel->relabel &&
|
if (seclabel->relabel &&
|
||||||
(!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
|
(!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
|
||||||
seclabel->type != VIR_DOMAIN_SECLABEL_NONE)) {
|
seclabel->type != VIR_DOMAIN_SECLABEL_NONE)) {
|
||||||
p = virXPathStringLimit("string(./imagelabel[1])",
|
seclabel->imagelabel = virXPathStringLimit("string(./imagelabel[1])",
|
||||||
VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
|
VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
|
||||||
if (p == NULL) {
|
if (!seclabel->imagelabel) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("security imagelabel is missing"));
|
"%s", _("security imagelabel is missing"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
seclabel->imagelabel = g_steal_pointer(&p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only parse baselabel for dynamic label type */
|
/* Only parse baselabel for dynamic label type */
|
||||||
if (seclabel->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
|
if (seclabel->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
|
||||||
p = virXPathStringLimit("string(./baselabel[1])",
|
seclabel->baselabel = virXPathStringLimit("string(./baselabel[1])",
|
||||||
VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
|
VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
|
||||||
seclabel->baselabel = g_steal_pointer(&p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return seclabel;
|
return seclabel;
|
||||||
|
Loading…
Reference in New Issue
Block a user