[pve-devel] [PATCH v2 qemu-server 2/3] drive: use more compact for-loop expression for initializing drive descriptions
Oguz Bektas
o.bektas at proxmox.com
Mon May 18 17:34:03 CEST 2020
Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
PVE/QemuServer/Drive.pm | 25 ++++++-------------------
1 file changed, 6 insertions(+), 19 deletions(-)
diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm
index b8a553a..5dc5508 100644
--- a/PVE/QemuServer/Drive.pm
+++ b/PVE/QemuServer/Drive.pm
@@ -367,32 +367,19 @@ my $unuseddesc = {
description => "Reference to unused volumes. This is used internally, and should not be modified manually.",
};
-for (my $i = 0; $i < $MAX_IDE_DISKS; $i++) {
- $drivedesc_hash->{"ide$i"} = $idedesc;
-}
+$drivedesc_hash->{"ide$_"} = $idedesc for (0..$MAX_IDE_DISKS);
-for (my $i = 0; $i < $MAX_SATA_DISKS; $i++) {
- $drivedesc_hash->{"sata$i"} = $satadesc;
-}
+$drivedesc_hash->{"sata$_"} = $satadesc for (0..$MAX_SATA_DISKS);
-for (my $i = 0; $i < $MAX_SCSI_DISKS; $i++) {
- $drivedesc_hash->{"scsi$i"} = $scsidesc;
-}
+$drivedesc_hash->{"scsi$_"} = $scsidesc for (0..$MAX_SCSI_DISKS);
-for (my $i = 0; $i < $MAX_NVME_DISKS; $i++) {
- $drivedesc_hash->{"nvme$i"} = $nvmedesc;
-}
+$drivedesc_hash->{"nvme$_"} = $nvmedesc for (0..$MAX_NVME_DISKS);
-
-for (my $i = 0; $i < $MAX_VIRTIO_DISKS; $i++) {
- $drivedesc_hash->{"virtio$i"} = $virtiodesc;
-}
+$drivedesc_hash->{"virtio$_"} = $virtiodesc for (0..$MAX_VIRTIO_DISKS);
$drivedesc_hash->{efidisk0} = $efidisk_desc;
-for (my $i = 0; $i < $MAX_UNUSED_DISKS; $i++) {
- $drivedesc_hash->{"unused$i"} = $unuseddesc;
-}
+$drivedesc_hash->{"unused$_"} = $unuseddesc for (0..$MAX_UNUSED_DISKS);
sub valid_drive_names {
# order is important - used to autoselect boot disk
--
2.20.1
More information about the pve-devel
mailing list