[pve-devel] [PATCH v1 pve-common 05/18] pbsclient: use cond. statements instead of chained 'or' operators
Thomas Lamprecht
t.lamprecht at proxmox.com
Mon Nov 11 20:10:58 CET 2024
Am 02.08.24 um 15:26 schrieb Max Carrara:
> .. 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";
we have this pattern quite often and for unlink this is IMO really fine to do,
especially with replacing `$! == ENOENT` with `$!{ENOENT}` to avoid the need
for loading the POSIX module.
> + if (!unlink($pwfile)) {
> + return if $! == ENOENT;
> + die "deleting password file failed - $!\n";
> + }
> };
>
> sub get_password {
More information about the pve-devel
mailing list