]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virXMLPropULongLong: Always initialize @result
authorPeter Krempa <pkrempa@redhat.com>
Thu, 6 May 2021 12:00:16 +0000 (14:00 +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 9929064993d4f481259dba8bbbc73e3851c147af..707a6a2235ff8564270a044cb52eba66bb728ef8 100644 (file)
@@ -762,6 +762,7 @@ virXMLPropUInt(xmlNodePtr node,
  * @result: The returned value
  *
  * Convenience function to return value of an unsigned long long attribute.
+ * @result is initialized to 0 on error or if the element is not found.
  *
  * Returns 1 in case of success in which case @result is set,
  *         or 0 if the attribute is not present,
@@ -778,6 +779,8 @@ virXMLPropULongLong(xmlNodePtr node,
     int ret;
     unsigned long long val;
 
+    *result = 0;
+
     if (!(tmp = virXMLPropString(node, name))) {
         if (!(flags & VIR_XML_PROP_REQUIRED))
             return 0;