Properly check the return value of CCWAddressAsString

It returns NULL on failure. Checking if the negation of it
is less than zero makes no sense. (Found by coverity after moving
the code)

In another case, the return value wasn't checked at all.
This commit is contained in:
Ján Tomko 2014-06-23 08:31:53 +02:00
parent b2626755d3
commit 3fe9d75ab6

View File

@ -614,7 +614,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
goto cleanup;
}
} else if (autoassign && !dev->addr.ccw.assigned) {
if (!(addr = virDomainCCWAddressAsString(&addrs->next)) < 0)
if (!(addr = virDomainCCWAddressAsString(&addrs->next)))
goto cleanup;
while (virHashLookup(addrs->defined, addr)) {
@ -624,7 +624,8 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
goto cleanup;
}
VIR_FREE(addr);
addr = virDomainCCWAddressAsString(&addrs->next);
if (!(addr = virDomainCCWAddressAsString(&addrs->next)))
goto cleanup;
}
dev->addr.ccw = addrs->next;
dev->addr.ccw.assigned = true;