]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virSecurityLabelDefParseXML: Directly assign strings into appropriate variables
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 Nov 2021 15:33:37 +0000 (16:33 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 24 Nov 2021 08:20:38 +0000 (09:20 +0100)
'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>
src/conf/domain_conf.c

index ba38d510dd4d96359722c79ddd0e17976f8fa17f..24de57005c4c3e4ffbc84476071d5ad543b20155 100644 (file)
@@ -7874,36 +7874,32 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
     if (seclabel->type == VIR_DOMAIN_SECLABEL_STATIC ||
         (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
          seclabel->type != VIR_DOMAIN_SECLABEL_NONE)) {
-        p = virXPathStringLimit("string(./label[1])",
-                                VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
-        if (p == NULL) {
+        seclabel->label = virXPathStringLimit("string(./label[1])",
+                                              VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
+        if (!seclabel->label) {
             virReportError(VIR_ERR_XML_ERROR,
                            "%s", _("security label is missing"));
             goto error;
         }
-
-        seclabel->label = g_steal_pointer(&p);
     }
 
     /* Only parse imagelabel, if requested live XML with relabeling */
     if (seclabel->relabel &&
         (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
          seclabel->type != VIR_DOMAIN_SECLABEL_NONE)) {
-        p = virXPathStringLimit("string(./imagelabel[1])",
-                                VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
-        if (p == NULL) {
+        seclabel->imagelabel = virXPathStringLimit("string(./imagelabel[1])",
+                                                   VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
+        if (!seclabel->imagelabel) {
             virReportError(VIR_ERR_XML_ERROR,
                            "%s", _("security imagelabel is missing"));
             goto error;
         }
-        seclabel->imagelabel = g_steal_pointer(&p);
     }
 
     /* Only parse baselabel for dynamic label type */
     if (seclabel->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
-        p = virXPathStringLimit("string(./baselabel[1])",
-                                VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
-        seclabel->baselabel = g_steal_pointer(&p);
+        seclabel->baselabel = virXPathStringLimit("string(./baselabel[1])",
+                                                  VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
     }
 
     return seclabel;