]> xenbits.xensource.com Git - libvirt.git/commitdiff
virXMLPropTristateBool: Always initialize '@result'
authorPeter Krempa <pkrempa@redhat.com>
Thu, 6 May 2021 12:35:22 +0000 (14:35 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 7 May 2021 08:06:18 +0000 (10:06 +0200)
Compilers aren't able to see whether @result is set or not and thus
don't warn of a potential use of uninitialized value. Always set @result
to prevent uninitialized use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virxml.c

index 449453121f01be1449f5c0b6887a1248da0ec4ca..d9bc5199b3e42642587a1aa749ab34f9f9eb8f4f 100644 (file)
@@ -600,6 +600,8 @@ virXMLPropEnumInternal(xmlNodePtr node,
  * @result: The returned value
  *
  * Convenience function to return value of a yes / no attribute.
+ * In case when the property is missing @result is initialized to
+ * VIR_TRISTATE_BOOL_ABSENT.
  *
  * Returns 1 in case of success in which case @result is set,
  *         or 0 if the attribute is not present,
@@ -613,6 +615,8 @@ virXMLPropTristateBool(xmlNodePtr node,
 {
     flags |= VIR_XML_PROP_NONZERO;
 
+    *result = VIR_TRISTATE_BOOL_ABSENT;
+
     return virXMLPropEnumInternal(node, name, virTristateBoolTypeFromString,
                                   flags, result);
 }