mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
virXMLPropEnum: Always initialize '@result'
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>
This commit is contained in:
parent
e06c6fdbdc
commit
1764b305e6
@ -562,12 +562,15 @@ virXMLPropEnumInternal(xmlNodePtr node,
|
|||||||
const char* name,
|
const char* name,
|
||||||
int (*strToInt)(const char*),
|
int (*strToInt)(const char*),
|
||||||
virXMLPropFlags flags,
|
virXMLPropFlags flags,
|
||||||
unsigned int *result)
|
unsigned int *result,
|
||||||
|
unsigned int defaultResult)
|
||||||
|
|
||||||
{
|
{
|
||||||
g_autofree char *tmp = NULL;
|
g_autofree char *tmp = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
*result = defaultResult;
|
||||||
|
|
||||||
if (!(tmp = virXMLPropString(node, name))) {
|
if (!(tmp = virXMLPropString(node, name))) {
|
||||||
if (!(flags & VIR_XML_PROP_REQUIRED))
|
if (!(flags & VIR_XML_PROP_REQUIRED))
|
||||||
return 0;
|
return 0;
|
||||||
@ -615,10 +618,8 @@ virXMLPropTristateBool(xmlNodePtr node,
|
|||||||
{
|
{
|
||||||
flags |= VIR_XML_PROP_NONZERO;
|
flags |= VIR_XML_PROP_NONZERO;
|
||||||
|
|
||||||
*result = VIR_TRISTATE_BOOL_ABSENT;
|
|
||||||
|
|
||||||
return virXMLPropEnumInternal(node, name, virTristateBoolTypeFromString,
|
return virXMLPropEnumInternal(node, name, virTristateBoolTypeFromString,
|
||||||
flags, result);
|
flags, result, VIR_TRISTATE_BOOL_ABSENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -645,10 +646,8 @@ virXMLPropTristateSwitch(xmlNodePtr node,
|
|||||||
{
|
{
|
||||||
flags |= VIR_XML_PROP_NONZERO;
|
flags |= VIR_XML_PROP_NONZERO;
|
||||||
|
|
||||||
*result = VIR_TRISTATE_SWITCH_ABSENT;
|
|
||||||
|
|
||||||
return virXMLPropEnumInternal(node, name, virTristateSwitchTypeFromString,
|
return virXMLPropEnumInternal(node, name, virTristateSwitchTypeFromString,
|
||||||
flags, result);
|
flags, result, VIR_TRISTATE_SWITCH_ABSENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -851,9 +850,7 @@ virXMLPropEnumDefault(xmlNodePtr node,
|
|||||||
unsigned int *result,
|
unsigned int *result,
|
||||||
unsigned int defaultResult)
|
unsigned int defaultResult)
|
||||||
{
|
{
|
||||||
*result = defaultResult;
|
return virXMLPropEnumInternal(node, name, strToInt, flags, result, defaultResult);
|
||||||
|
|
||||||
return virXMLPropEnumInternal(node, name, strToInt, flags, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -867,6 +864,7 @@ virXMLPropEnumDefault(xmlNodePtr node,
|
|||||||
* @result: The returned value
|
* @result: The returned value
|
||||||
*
|
*
|
||||||
* Convenience function to return value of an enum attribute.
|
* Convenience function to return value of an enum 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,
|
* Returns 1 in case of success in which case @result is set,
|
||||||
* or 0 if the attribute is not present,
|
* or 0 if the attribute is not present,
|
||||||
@ -879,7 +877,7 @@ virXMLPropEnum(xmlNodePtr node,
|
|||||||
virXMLPropFlags flags,
|
virXMLPropFlags flags,
|
||||||
unsigned int *result)
|
unsigned int *result)
|
||||||
{
|
{
|
||||||
return virXMLPropEnumInternal(node, name, strToInt, flags, result);
|
return virXMLPropEnumInternal(node, name, strToInt, flags, result, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user