DBus/Parser/UnixFDs.pm

filter: Statementstmt 35.0% 7 / 20 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 0.0% 0 / 1 totaltotal 28.1% 9 / 32 SCAR 30.5
CC
6
Cov
25%
extract_from_msghdr
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 21.2
« DBus/Authn/Mechanism/EXTERNAL.pm ↑ Summary DBus/Client.pm »
1 package Protocol::DBus::Parser::UnixFDs;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 sub extract_from_msghdr {
7 0 ▶ my ($msg) = @_;
Subroutine extract_from_msghdr: not called CC=6 SCAR=37.4
Pod undocumented
8  
9 0 my @all_control = $msg->cmsghdr();
10  
11 0 my @fhs;
12  
13 0 ▶ while (@all_control) {
Branch: 1 branch
BranchTrueFalseTotal
if (@all_control) 0 0 0
14 0 my ($level, $type, $data) = splice @all_control, 0, 3;
15 0 ▶ if ($level != Socket::SOL_SOCKET()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level != 1) 0 0 0
16 0 die "Unknown control message level: $level";
17 }
18  
19 0 ▶ if ($type != Socket::SCM_RIGHTS()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type != 1) 0 0 0
20 0 die "Unknown control message type: $type";
21 }
22  
23 0 for my $fd ( unpack 'I!*', $data ) {
24  
25 # The mode is immaterial except to
26 # avoid Perl complaining about STDOUT
27 # being reopened as read or something.
28 # The kernel should not care.
29 0 ▶ open my $fh, '+<&=', $fd or die "open() to reuse FD $fd: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "+<&=", $fd or die "open() to reuse FD ${fd}: $!" 0 0 0
30  
31 # Would it be worthwhile to fcntl()
32 # here to determine what the actual
33 # access mode is and re-open() with
34 # that mode?
35  
36 0 push @fhs, $fh;
37 }
38 }
39  
40 0 return @fhs;
41 }
42  
43 1 1;
« DBus/Authn/Mechanism/EXTERNAL.pm ↑ Summary DBus/Client.pm »