[pve-devel] [PATCH v1 pve-common 05/18] pbsclient: use cond. statements instead of chained 'or' operators

Max Carrara m.carrara at proxmox.com
Fri Aug 2 15:26:43 CEST 2024


.. like in the `delete_encryption_key` subroutine below, as it's more
readable at a glance.

Signed-off-by: Max Carrara <m.carrara at proxmox.com>
---
 src/PVE/PBSClient.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/PVE/PBSClient.pm b/src/PVE/PBSClient.pm
index ab1fa62..d707971 100644
--- a/src/PVE/PBSClient.pm
+++ b/src/PVE/PBSClient.pm
@@ -77,7 +77,10 @@ sub delete_password {
 
     my $pwfile = password_file_name($self);
 
-    unlink $pwfile or $! == ENOENT or die "deleting password file failed - $!\n";
+    if (!unlink($pwfile)) {
+	return if $! == ENOENT;
+	die "deleting password file failed - $!\n";
+    }
 };
 
 sub get_password {
-- 
2.39.2





More information about the pve-devel mailing list