pack_numeric.c

filter: Statementstmt 97.2% 35 / 36 Branchbran 83.3% 15 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 92.5% 50 / 54 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« enums.c ↑ Summary pack_result_response.c »
1 #include "pack.h"
2  
3 45 void pack_unsigned_numeric_notag(SV* dest, U32 l) {
4 char buffer[10];
5 45 char *p = buffer + 1;
6 45 int len, i = sizeof(U32);
7  
8 155 ▶ while (--i > 0)
Branch: 1 branch
BranchTrueFalseTotal
while (--i > 0) 131 24 155
9 131 ▶ if (l >> (i * 8)) break;
Branch: 1 branch
BranchTrueFalseTotal
if (l >> (i * 8)) break; 21 110 131
10  
11 45 ▶ if ((l >> (i * 8)) & 0x80)
Branch: 1 branch
BranchTrueFalseTotal
if ((l >> (i * 8)) & 0x80) 11 34 45
12 11 *p++ = 0;
13  
14 do {
15 70 *p++ = ((l >> (i * 8)) & 0xff);
16 70 ▶ } while (--i >= 0);
Branch: 1 branch
BranchTrueFalseTotal
} while (--i >= 0); 25 45 70
17  
18 45 len = p - buffer;
19 45 buffer[0] = len - 1;
20 45 sv_catpvn(dest, buffer, len);
21 45 }
22  
23 43 void pack_numeric_notag(SV* dest, I32 l) {
24 43 ▶ if (l >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (l >= 0) 29 14 43
25 29 pack_unsigned_numeric_notag(dest, l);
26 else {
27 char buffer[10];
28 14 char *p = buffer + 1;
29 14 int len, i = sizeof(I32);
30
31 56 ▶ while(--i > 0)
Branch: 1 branch
BranchTrueFalseTotal
while(--i > 0) 42 14 56
32 42 ▶ if (((l >> (i * 8)) & 0xff) != 0xff) break;
Branch: 1 branch
BranchTrueFalseTotal
if (((l >> (i * 8)) & 0xff) != 0xff) break; 0 42 42
33
34 14 ▶ if (!(l >> (i * 8) & 0x80))
Branch: 1 branch
BranchTrueFalseTotal
if (!(l >> (i * 8) & 0x80)) 0 14 14
35 0 *p++ = 0xff;
36
37 do {
38 14 *p++ = ((l >> (i * 8)) & 0xff);
39 14 ▶ } while (--i >= 0);
Branch: 1 branch
BranchTrueFalseTotal
} while (--i >= 0); 0 14 14
40  
41 14 len = p - buffer;
42 14 buffer[0] = len - 1;
43 14 sv_catpvn(dest, buffer, len);
44 }
45 43 }
46  
47 16 void pack_unsigned_numeric(SV* dest, U8 type, U32 tag, U32 l) {
48 16 pack_tag(dest, type, tag);
49 16 pack_unsigned_numeric_notag(dest, l);
50 16 }
51  
52 43 void pack_numeric(SV* dest, U8 type, U32 tag, I32 l) {
53 43 pack_tag(dest, type, tag);
54 43 pack_numeric_notag(dest, l);
55 43 }
« enums.c ↑ Summary pack_result_response.c »