GCC Code Coverage Report


Directory: ./
File: firmware/util/math/crc8hondak.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 18 0 18
Functions: 100.0% 4 0 4
Branches: 87.5% 7 0 8
Decisions: 83.3% 5 - 6

Line Branch Decision Exec Source
1 #include <stddef.h>
2 #include <stdint.h>
3
4 #include "crc8hondak.h"
5
6 2 static inline uint8_t crc_init(void)
7 {
8 2 return 0xff;
9 }
10
11 7 static inline uint8_t crc_next(uint8_t crc, uint8_t data)
12 {
13 uint8_t eor;
14 7 unsigned int i = 8;
15
16 7 crc ^= data;
17 do {
18 /* This might produce branchless code */
19
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
56 eor = crc & 1 ? 0xb8 : 0;
20 56 crc >>= 1;
21 56 crc ^= eor;
22
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 7 times.
2/2
✓ Decision 'true' taken 49 times.
✓ Decision 'false' taken 7 times.
56 } while (--i);
23
24 7 return crc;
25 }
26
27 2 static inline uint8_t crc_final(uint8_t crc) {
28 2 return ~crc;
29 }
30
31 2 uint8_t crc_hondak_calc(const uint8_t *data, size_t len) {
32 2 uint8_t crc = crc_init();
33
34
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
1/2
✓ Decision 'true' taken 2 times.
✗ Decision 'false' not taken.
2 if (len) do {
35 7 crc = crc_next(crc, *data++);
36
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
2/2
✓ Decision 'true' taken 5 times.
✓ Decision 'false' taken 2 times.
7 } while (--len);
37
38 2 return crc_final(crc);
39 }
40