mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +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;
|
size_t i;
|
||||||
virStorageSourcePtr tmp = NULL;
|
virStorageSourcePtr tmp = NULL;
|
||||||
|
|
||||||
if (src)
|
if (!src)
|
||||||
*src = NULL;
|
src = &tmp;
|
||||||
|
|
||||||
for (i = 0; i < def->ndisks; i++) {
|
for (i = 0; i < def->ndisks; i++) {
|
||||||
if ((tmp = virStorageSourceFindByNodeName(def->disks[i]->src, nodename))) {
|
virDomainDiskDefPtr domdisk = def->disks[i];
|
||||||
if (src)
|
|
||||||
*src = tmp;
|
|
||||||
|
|
||||||
return def->disks[i];
|
if ((*src = virStorageSourceFindByNodeName(domdisk->src, nodename)))
|
||||||
}
|
return domdisk;
|
||||||
|
|
||||||
if (def->disks[i]->mirror &&
|
if (domdisk->mirror &&
|
||||||
(tmp = virStorageSourceFindByNodeName(def->disks[i]->mirror, nodename))) {
|
(*src = virStorageSourceFindByNodeName(domdisk->mirror, nodename)))
|
||||||
if (src)
|
return domdisk;
|
||||||
*src = tmp;
|
|
||||||
|
|
||||||
return def->disks[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user