mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 07:05:28 +00:00
Fix warning about using an uninitialized next_unit value
Using an uninitialized value and a bool saying if the value is valid may confuse compilators.
This commit is contained in:
parent
33e300229c
commit
4db39e3fee
@ -3883,36 +3883,36 @@ virDomainHostdevAssignAddress(virDomainXMLOptionPtr xmlopt,
|
|||||||
virDomainDefPtr def,
|
virDomainDefPtr def,
|
||||||
virDomainHostdevDefPtr hostdev)
|
virDomainHostdevDefPtr hostdev)
|
||||||
{
|
{
|
||||||
int next_unit;
|
int next_unit = 0;
|
||||||
unsigned nscsi_controllers = 0;
|
unsigned controller = 0;
|
||||||
bool found = false;
|
|
||||||
int i;
|
int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
|
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < def->ncontrollers && !found; i++) {
|
for (i = 0; i < def->ncontrollers; i++) {
|
||||||
if (def->controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
|
if (def->controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
nscsi_controllers++;
|
controller++;
|
||||||
next_unit = virDomainControllerSCSINextUnit(def,
|
ret = virDomainControllerSCSINextUnit(def,
|
||||||
xmlopt->config.hasWideScsiBus ?
|
xmlopt->config.hasWideScsiBus ?
|
||||||
SCSI_WIDE_BUS_MAX_CONT_UNIT :
|
SCSI_WIDE_BUS_MAX_CONT_UNIT :
|
||||||
SCSI_NARROW_BUS_MAX_CONT_UNIT,
|
SCSI_NARROW_BUS_MAX_CONT_UNIT,
|
||||||
def->controllers[i]->idx);
|
def->controllers[i]->idx);
|
||||||
if (next_unit >= 0)
|
if (ret >= 0) {
|
||||||
found = true;
|
next_unit = ret;
|
||||||
|
controller = def->controllers[i]->idx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hostdev->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE;
|
hostdev->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE;
|
||||||
|
hostdev->info->addr.drive.controller = controller;
|
||||||
hostdev->info->addr.drive.controller = found ?
|
|
||||||
def->controllers[i - 1]->idx :
|
|
||||||
nscsi_controllers;
|
|
||||||
hostdev->info->addr.drive.bus = 0;
|
hostdev->info->addr.drive.bus = 0;
|
||||||
hostdev->info->addr.drive.target = 0;
|
hostdev->info->addr.drive.target = 0;
|
||||||
hostdev->info->addr.drive.unit = found ? next_unit : 0;
|
hostdev->info->addr.drive.unit = next_unit;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user