Host C Specs


Directory: src/c/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 7 / 0 / 7
Functions: 100.0% 1 / 0 / 1
Branches: 100.0% 2 / 0 / 2

pebble/io/stores/store_sum.c
Line Branch Exec Source
1 /**
2 * @file store_sum.c
3 * @brief The checksum the stores compare before saving, in one copy every store links against.
4 *
5 * @ingroup lib_stores
6 */
7 #include "io/stores/store_sum.h"
8
9 6 uint32_t store_sum(const void *bytes, size_t size)
10 {
11 // FNV-1a. each byte is mixed in turn, so the order of the bytes counts as well as their values
12 6 const uint8_t *byte = (const uint8_t *)bytes;
13 6 uint32_t sum = 2166136261u;
14
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 6 times.
74 for (size_t i = 0; i < size; i++)
15 {
16 68 sum ^= byte[i];
17 68 sum *= 16777619u;
18 }
19 6 return sum;
20 }
21