The function replaces the open-coded block. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f5d4e468ce..e56351333c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9954,7 +9954,6 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr, virStorageSourcePtr src = NULL; g_autofree char *target = NULL; unsigned int idx; - size_t i; if (virStorageFileParseBackingStoreStr(devstr, &target, &idx) < 0) { virReportError(VIR_ERR_INVALID_ARG, @@ -9962,14 +9961,7 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr, return NULL; } - for (i = 0; i < def->ndisks; i++) { - if (STREQ(target, def->disks[i]->dst)) { - disk = def->disks[i]; - break; - } - } - - if (!disk) { + if (!(disk = virDomainDiskByTarget(def, target))) { virReportError(VIR_ERR_INVALID_ARG, _("failed to find disk '%s'"), target); return NULL; -- 2.28.0