DBus/Parser/UnixFDs.pm

filter: Statementstmt 90.0% 18 / 20 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 81.2% 26 / 32 SCAR 18.3
CC
6
Cov
82%
extract_from_msghdr
6.5
BEGIN
1.0
BEGIN
1.0
CRAP 6.2
« DBus/Message/Header.pm ↑ Summary DBus/Connect.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 1 ▶ my ($msg) = @_;
Subroutine extract_from_msghdr: called CC=6 SCAR=18.7
Pod undocumented
8  
9 1 my @all_control = $msg->cmsghdr();
10  
11 1 my @fhs;
12  
13 1 ▶ while (@all_control) {
Branch: 1 branch
BranchTrueFalseTotal
if (@all_control) 1 1 2
14 1 my ($level, $type, $data) = splice @all_control, 0, 3;
15 1 ▶ if ($level != Socket::SOL_SOCKET()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level != 1) 0 1 1
16 0 die "Unknown control message level: $level";
17 }
18  
19 1 ▶ if ($type != Socket::SCM_RIGHTS()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type != 1) 0 1 1
20 0 die "Unknown control message type: $type";
21 }
22  
23 1 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 2 ▶ 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 2 2
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 2 push @fhs, $fh;
37 }
38 }
39  
40 1 return @fhs;
41 }
42  
43 1 1;
« DBus/Message/Header.pm ↑ Summary DBus/Connect.pm »