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 <pkre...@redhat.com>
---
 src/util/virxml.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/util/virxml.c b/src/util/virxml.c
index 449453121f..d9bc5199b3 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -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);
 }
-- 
2.30.2

Reply via email to