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@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2275c83aa8..f5d4e468ce 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9911,24 +9911,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 (def->disks[i]->mirror && - (tmp = virStorageSourceFindByNodeName(def->disks[i]->mirror, nodename))) { - if (src) - *src = tmp; + if ((*src = virStorageSourceFindByNodeName(domdisk->src, nodename))) + return domdisk; - return def->disks[i]; - } + if (domdisk->mirror && + (*src = virStorageSourceFindByNodeName(domdisk->mirror, nodename))) + return domdisk; } return NULL; -- 2.28.0