提交 cda1cc17 编写于 作者: A Andrea Bolognani

conf: Use a temporary int variable to store GIC version

Since no value in the virGICVersion enumeration is negative, a clever
enough compiler can report an error such as

  src/conf/domain_conf.c:15337:75: error: comparison of unsigned enum
  expression < 0 is always false [-Werror,-Wtautological-compare]
    if ((def->gic_version = virGICVersionTypeFromString(tmp)) < 0 ||
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~

virGICVersionTypeFromString() can, however, return a negative value if
the input string is not part of the enumeration, so we definitely need
that check.

Work around the problem by storing the return value in a temporary int
variable.
上级 731ed05c
......@@ -14728,7 +14728,7 @@ virDomainDefParseXML(xmlDocPtr xml,
xmlNodePtr *nodes = NULL, node = NULL;
char *tmp = NULL;
size_t i, j;
int n, virtType;
int n, virtType, gic_version;
long id = -1;
virDomainDefPtr def;
bool uuid_generated = false;
......@@ -15334,12 +15334,13 @@ virDomainDefParseXML(xmlDocPtr xml,
node = ctxt->node;
ctxt->node = nodes[i];
if ((tmp = virXPathString("string(./@version)", ctxt))) {
if ((def->gic_version = virGICVersionTypeFromString(tmp)) < 0 ||
def->gic_version == VIR_GIC_VERSION_NONE) {
gic_version = virGICVersionTypeFromString(tmp);
if (gic_version < 0 || gic_version == VIR_GIC_VERSION_NONE) {
virReportError(VIR_ERR_XML_ERROR,
_("malformed gic version: %s"), tmp);
goto error;
}
def->gic_version = gic_version;
VIR_FREE(tmp);
}
def->features[val] = VIR_TRISTATE_SWITCH_ON;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册