]> git.proxmox.com Git - pve-common.git/commitdiff
various perl critic fixes
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 11 Apr 2023 14:17:10 +0000 (16:17 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 11 Apr 2023 14:17:10 +0000 (16:17 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/CpuSet.pm
src/PVE/Daemon.pm
src/PVE/RESTEnvironment.pm
src/PVE/SectionConfig.pm
src/PVE/Syscall.pm

index 12bda2ce07a912d2a82ad208b507727bd7783a48..1292558359777c19387a1958efab1906c0248f37 100644 (file)
@@ -131,7 +131,8 @@ sub has {
 sub members {
     my ($self) = @_;
 
-    return sort { $a <=> $b } keys %{$self->{members}};
+    my @sorted_members = sort { $a <=> $b } keys %{$self->{members}};
+    return @sorted_members;
 }
 
 sub size {
index 032cb279171b051344ba69ca0f830750ccbf0128..63fd5eed29195d8f07f8400e2a066481347df448 100644 (file)
@@ -114,10 +114,10 @@ my $writepidfile = sub {
 
     my $pidfile = $self->{pidfile};
 
-    die "can't open pid file '$pidfile' - $!\n" if !open (PIDFH, ">$pidfile");
+    open (my $PID_FH, '>', "$pidfile") or die "can't open pid file '$pidfile' - $!\n";
 
-    print PIDFH "$$\n";
-    close (PIDFH);
+    print $PID_FH "$$\n";
+    close ($PID_FH);
 };
 
 my $server_cleanup = sub {
@@ -310,8 +310,8 @@ my $server_run = sub {
     $self->init();
 
     if (!$debug) {
-       open STDIN,  '</dev/null' || die "can't read /dev/null";
-       open STDOUT, '>/dev/null' || die "can't write /dev/null";
+       open STDIN,  '<', '/dev/null' or die "can't read /dev/null - $!";
+       open STDOUT, '>', '/dev/null' or die "can't write /dev/null - $!";
     }
 
     if (!$self->{env_restart_pve_daemon} && !$debug) {
index 89def38354b061e606ed6f60075dae396bb0e596..191c6ebf6f62250b47c7b4aee163d2adeb847685 100644 (file)
@@ -431,7 +431,7 @@ my $tee_worker = sub {
        };
        local $SIG{PIPE} = sub { die "broken pipe\n"; };
 
-       my $select = new IO::Select;
+       my $select = IO::Select->new();
        my $fh = IO::Handle->new_from_fd($childfd, 'r');
        $select->add($fh);
 
@@ -509,7 +509,7 @@ sub fork_worker {
 
     my @psync = POSIX::pipe();
     my @csync = POSIX::pipe();
-    my @ctrlfd = POSIX::pipe() if $sync;
+    my @ctrlfd = $sync ? POSIX::pipe() : ();
 
     my $node = $self->{nodename};
 
@@ -571,8 +571,7 @@ sub fork_worker {
                close STDIN;
                POSIX::close(0) if $fd != 0;
 
-               die "unable to redirect STDIN - $!"
-                   if !open(STDIN, "</dev/null");
+               open(STDIN, '<', '/dev/null') or die "unable to redirect STDIN - $!";
 
                $outfh = PVE::Tools::upid_open($upid);
                $resfh = fileno($outfh);
@@ -584,8 +583,7 @@ sub fork_worker {
            close STDOUT;
            POSIX::close (1) if $fd != 1;
 
-           die "unable to redirect STDOUT - $!"
-               if !open(STDOUT, ">&", $outfh);
+           open(STDOUT, ">&", $outfh) or die "unable to redirect STDOUT - $!";
 
            STDOUT->autoflush (1);
 
@@ -594,8 +592,7 @@ sub fork_worker {
            close STDERR;
            POSIX::close(2) if $fd != 2;
 
-           die "unable to redirect STDERR - $!"
-               if !open(STDERR, ">&1");
+           open(STDERR, '>&', '1') or die "unable to redirect STDERR - $!";
 
            STDERR->autoflush(1);
        };
index e3546559d29f581f79f493533c4e7bc4805d036a..f36cede9f75ba27e9591571b0e09fd924e84328d 100644 (file)
@@ -115,7 +115,7 @@ sub updateSchema {
 
     my $props = {};
 
-    my $filter_type = $class->type() if $single_class;
+    my $filter_type = $single_class ? $class->type() : undef;
 
     foreach my $p (keys %$propertyList) {
        next if $p eq 'type';
index ee374d80932568a66df1281baf24d1221144c260..4c0b9cf13caac0fb76d0e271e4f0cd7b1638b2bd 100644 (file)
@@ -1,5 +1,8 @@
 package PVE::Syscall;
 
+use strict;
+use warnings;
+
 my %syscalls;
 my %fsmount_constants;
 BEGIN {