]> git.proxmox.com Git - pve-common.git/commitdiff
procfs tools: modernize write_proc_entry
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 13 Nov 2022 12:54:57 +0000 (13:54 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 13 Nov 2022 12:54:59 +0000 (13:54 +0100)
that unless stuff is just hard to read and against our code style.

note that there's also basically the same helper in SysFSTools, and
neither is really dependent on sysfs or procfs semantics, so both
probably should go away..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/ProcFSTools.pm

index d636427688d2554254505012e71e7b8160b204aa..eb4b0f5be92197b83dfc5fc22f156e5fd2aca034 100644 (file)
@@ -352,10 +352,10 @@ sub read_proc_net_dev {
 sub write_proc_entry {
     my ($filename, $data) = @_;#
 
-    my $fh = IO::File->new($filename,  O_WRONLY);
+    my $fh = IO::File->new($filename, O_WRONLY);
     die "unable to open file '$filename' - $!\n" if !$fh;
-    die "unable to write '$filename' - $!\n" unless print $fh $data;
-    die "closing file '$filename' failed - $!\n" unless close $fh;
+    print $fh $data or die "unable to write '$filename' - $!\n";
+    close $fh or die "closing file '$filename' failed - $!\n";
     $fh->close();
 }