]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
syscall: `use bytes' throughout
authorEric Wong <e@80x24.org>
Sat, 8 Feb 2025 03:26:33 +0000 (03:26 +0000)
committerEric Wong <e@80x24.org>
Tue, 11 Feb 2025 00:11:39 +0000 (00:11 +0000)
All *nix syscalls operate on the byte-level with no knowledge of
encodings, so ensure all `substr' and `length' calculations use
the bytes(3perl) pragma.

lib/PublicInbox/Syscall.pm

index e5e3340fa11123e52c38d48135330196a6bf6154..d005fecb603772d981a7eec76c0c966d3b0e09c2 100644 (file)
@@ -18,6 +18,7 @@
 package PublicInbox::Syscall;
 use v5.12;
 use parent qw(Exporter);
+use bytes qw(length substr);
 use POSIX qw(ENOENT ENOSYS EINVAL O_NONBLOCK);
 use Socket qw(SOL_SOCKET SCM_RIGHTS);
 use Config;
@@ -544,7 +545,6 @@ require PublicInbox::CmdIPC4;
 };
 
 *sendmsg_more = sub ($@) {
-       use bytes qw(length substr);
        my $sock = shift;
        my $iov = join('', map { pack 'P'.TMPL_size_t, $_, length } @_);
        my $mh = pack(TMPL_msghdr,
@@ -563,7 +563,6 @@ require PublicInbox::CmdIPC4;
 if (defined($SYS_writev)) {
 *writev = sub {
        my $fh = shift;
-       use bytes qw(length substr);
        my $iov = join('', map { pack 'P'.TMPL_size_t, $_, length } @_);
        my $w;
        do {