mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemuDomainDiskLookupByNodename: Simplify node name lookup
Use dummy variable to fill 'src' so that access to it doesn't need to be conditionalized and use temporary variable for 'disk' rather than dereferencing the array multiple times. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
b9dcaede65
commit
c3bb2b2d5d
@ -9910,24 +9910,18 @@ qemuDomainDiskLookupByNodename(virDomainDefPtr def,
|
||||
size_t i;
|
||||
virStorageSourcePtr tmp = NULL;
|
||||
|
||||
if (src)
|
||||
*src = NULL;
|
||||
if (!src)
|
||||
src = &tmp;
|
||||
|
||||
for (i = 0; i < def->ndisks; i++) {
|
||||
if ((tmp = virStorageSourceFindByNodeName(def->disks[i]->src, nodename))) {
|
||||
if (src)
|
||||
*src = tmp;
|
||||
virDomainDiskDefPtr domdisk = def->disks[i];
|
||||
|
||||
return def->disks[i];
|
||||
}
|
||||
if ((*src = virStorageSourceFindByNodeName(domdisk->src, nodename)))
|
||||
return domdisk;
|
||||
|
||||
if (def->disks[i]->mirror &&
|
||||
(tmp = virStorageSourceFindByNodeName(def->disks[i]->mirror, nodename))) {
|
||||
if (src)
|
||||
*src = tmp;
|
||||
|
||||
return def->disks[i];
|
||||
}
|
||||
if (domdisk->mirror &&
|
||||
(*src = virStorageSourceFindByNodeName(domdisk->mirror, nodename)))
|
||||
return domdisk;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user