提交 85d62624 编写于 作者: P Peter Krempa

conf: Don't assign value from ..TypeFromString directly to enum

Enums are unsigned, so it's impossible to check whether the helper
returned -1 for invalid conversions.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1452454
上级 dd875fb3
......@@ -14083,6 +14083,7 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode,
xmlNodePtr save = ctxt->node;
xmlNodePtr node;
virDomainMemoryDefPtr def;
int val;
ctxt->node = memdevNode;
......@@ -14102,12 +14103,14 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode,
}
VIR_FREE(tmp);
tmp = virXMLPropString(memdevNode, "access");
if (tmp &&
(def->access = virDomainMemoryAccessTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid access mode '%s'"), tmp);
goto error;
if ((tmp = virXMLPropString(memdevNode, "access"))) {
if ((val = virDomainMemoryAccessTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid access mode '%s'"), tmp);
goto error;
}
def->access = val;
}
VIR_FREE(tmp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册