[PATCH 05/17] virXMLPropUInt: Always initialize @result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/util/virxml.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/util/virxml.c b/src/util/virxml.c
index 707a6a2235..a03cbf7265 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -706,6 +706,7 @@ virXMLPropInt(xmlNodePtr node,
  * @result: The returned value
  *
  * Convenience function to return value of an unsigned integer 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,
@@ -722,6 +723,8 @@ virXMLPropUInt(xmlNodePtr node,
     int ret;
     unsigned int val;

+    *result = 0;
+
     if (!(tmp = virXMLPropString(node, name))) {
         if (!(flags & VIR_XML_PROP_REQUIRED))
             return 0;
-- 
2.30.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux