diff options
author | Eric Wong <e@80x24.org> | 2022-04-18 09:50:04 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-04-18 21:53:47 +0000 |
commit | d362af89d8019ff12d3550c83de2c3aa5d9f095b (patch) | |
tree | a93766da70f0b82530f4eb5add5fb2f1ee404e11 /lib | |
parent | 88c7c7c26b44ee4c1141fddb628a518b4d4d21a4 (diff) | |
download | public-inbox-d362af89d8019ff12d3550c83de2c3aa5d9f095b.tar.gz |
While `vec' is useful for user-supplied buffers to avoid excess memory traffic, but provides no benefit when we need to allocate our own buffers as we do in nodatacow_fh, since Perl can't elide memset(ptr, 0, len). So just use the idiomatic `"\0" x $LEN' here.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/Syscall.pm | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/PublicInbox/Syscall.pm b/lib/PublicInbox/Syscall.pm index cc282f9f..22b779ad 100644 --- a/lib/PublicInbox/Syscall.pm +++ b/lib/PublicInbox/Syscall.pm @@ -390,12 +390,10 @@ sub rename_noreplace ($$) { } } -sub nodatacow_fh { - return if !defined($SYS_fstatfs); - my $buf = ''; - vec($buf, 120 * 8 - 1, 1) = 0; +sub nodatacow_fh ($) { my ($fh) = @_; - syscall($SYS_fstatfs, fileno($fh), $buf) == 0 or + my $buf = "\0" x 120; + syscall($SYS_fstatfs // return, fileno($fh), $buf) == 0 or return warn("fstatfs: $!\n"); my $f_type = unpack('l!', $buf); # statfs.f_type is a signed word return if $f_type != 0x9123683E; # BTRFS_SUPER_MAGIC |