]> git.proxmox.com Git - qemu-server.git/commitdiff
cd rom handling: refactor cd rom path helper function
authorStefan Sterz <s.sterz@proxmox.com>
Tue, 20 Dec 2022 10:30:37 +0000 (11:30 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 13 Jan 2023 12:20:35 +0000 (13:20 +0100)
to stop returning results of assignments

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
PVE/QemuServer.pm

index ceb383204d5e052a45273b97046aeea944652cda..6155f4daf7d228d88f259ac68ea0f01d06ac89a5 100644 (file)
@@ -1289,12 +1289,16 @@ sub get_cdrom_path {
 
     return $cdrom_path if defined($cdrom_path);
 
-    return $cdrom_path = "/dev/cdrom" if -l "/dev/cdrom";
-    return $cdrom_path = "/dev/cdrom1" if -l "/dev/cdrom1";
-    return $cdrom_path = "/dev/cdrom2" if -l "/dev/cdrom2";
-
-    log_warn("no physical CD-ROM available, ignoring");
-    $cdrom_path = '';
+    if (-l "/dev/cdrom") {
+       $cdrom_path = "/dev/cdrom";
+    } elsif (-l "/dev/cdrom1") {
+       $cdrom_path = "/dev/cdrom1";
+    } elsif (-l "/dev/cdrom2") {
+       $cdrom_path = "/dev/cdrom2";
+    } else {
+       log_warn("no physical CD-ROM available, ignoring");
+       $cdrom_path = '';
+    }
 
     return $cdrom_path;
 }