mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 09:55:18 +00:00
virXMLPropTristateSwitch: 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. In two cases the code needed to be adjusted to preserve functionality. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
f66d7461d4
commit
3a658e2d2f
@ -17443,12 +17443,15 @@ virDomainFeaturesDefParse(virDomainDef *def,
|
||||
case VIR_DOMAIN_FEATURE_PVSPINLOCK:
|
||||
case VIR_DOMAIN_FEATURE_VMPORT:
|
||||
case VIR_DOMAIN_FEATURE_SMM: {
|
||||
virTristateSwitch state = VIR_TRISTATE_SWITCH_ON;
|
||||
virTristateSwitch state;
|
||||
|
||||
if (virXMLPropTristateSwitch(nodes[i], "state",
|
||||
VIR_XML_PROP_NONE, &state) < 0)
|
||||
return -1;
|
||||
|
||||
if (state == VIR_TRISTATE_SWITCH_ABSENT)
|
||||
state = VIR_TRISTATE_SWITCH_ON;
|
||||
|
||||
def->features[val] = state;
|
||||
break;
|
||||
}
|
||||
@ -17770,7 +17773,7 @@ virDomainFeaturesDefParse(virDomainDef *def,
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
virTristateSwitch state = VIR_TRISTATE_SWITCH_ON;
|
||||
virTristateSwitch state;
|
||||
int val = virDomainProcessCapsFeatureTypeFromString((const char *)nodes[i]->name);
|
||||
if (val < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
@ -17783,6 +17786,9 @@ virDomainFeaturesDefParse(virDomainDef *def,
|
||||
&state) < 0)
|
||||
return -1;
|
||||
|
||||
if (state == VIR_TRISTATE_SWITCH_ABSENT)
|
||||
state = VIR_TRISTATE_SWITCH_ON;
|
||||
|
||||
def->caps_features[val] = state;
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
@ -630,6 +630,8 @@ virXMLPropTristateBool(xmlNodePtr node,
|
||||
* @result: The returned value
|
||||
*
|
||||
* Convenience function to return value of an on / off attribute.
|
||||
* In case when the property is missing @result is initialized to
|
||||
* VIR_TRISTATE_SWITCH_ABSENT.
|
||||
*
|
||||
* Returns 1 in case of success in which case @result is set,
|
||||
* or 0 if the attribute is not present,
|
||||
@ -643,6 +645,8 @@ virXMLPropTristateSwitch(xmlNodePtr node,
|
||||
{
|
||||
flags |= VIR_XML_PROP_NONZERO;
|
||||
|
||||
*result = VIR_TRISTATE_SWITCH_ABSENT;
|
||||
|
||||
return virXMLPropEnumInternal(node, name, virTristateSwitchTypeFromString,
|
||||
flags, result);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user