fuzz coverage

Coverage Report

Created: 2025-09-17 22:41

/Users/eugenesiegel/btc/bitcoin/src/crypto/common.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) 2014-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef BITCOIN_CRYPTO_COMMON_H
6
#define BITCOIN_CRYPTO_COMMON_H
7
8
#include <compat/endian.h>
9
10
#include <concepts>
11
#include <cstddef>
12
#include <cstdint>
13
#include <cstring>
14
15
template <typename B>
16
concept ByteType = std::same_as<B, unsigned char> || std::same_as<B, std::byte>;
17
18
template <ByteType B>
19
inline uint16_t ReadLE16(const B* ptr)
20
0
{
21
0
    uint16_t x;
22
0
    memcpy(&x, ptr, 2);
23
0
    return le16toh_internal(x);
24
0
}
25
26
template <ByteType B>
27
inline uint32_t ReadLE32(const B* ptr)
28
568M
{
29
568M
    uint32_t x;
30
568M
    memcpy(&x, ptr, 4);
31
568M
    return le32toh_internal(x);
32
568M
}
_Z8ReadLE32ITk8ByteTypehEjPKT_
Line
Count
Source
28
370M
{
29
370M
    uint32_t x;
30
370M
    memcpy(&x, ptr, 4);
31
370M
    return le32toh_internal(x);
32
370M
}
_Z8ReadLE32ITk8ByteTypeSt4byteEjPKT_
Line
Count
Source
28
197M
{
29
197M
    uint32_t x;
30
197M
    memcpy(&x, ptr, 4);
31
197M
    return le32toh_internal(x);
32
197M
}
33
34
template <ByteType B>
35
inline uint64_t ReadLE64(const B* ptr)
36
434M
{
37
434M
    uint64_t x;
38
434M
    memcpy(&x, ptr, 8);
39
434M
    return le64toh_internal(x);
40
434M
}
_Z8ReadLE64ITk8ByteTypehEyPKT_
Line
Count
Source
36
424M
{
37
424M
    uint64_t x;
38
424M
    memcpy(&x, ptr, 8);
39
424M
    return le64toh_internal(x);
40
424M
}
_Z8ReadLE64ITk8ByteTypeSt4byteEyPKT_
Line
Count
Source
36
9.99M
{
37
9.99M
    uint64_t x;
38
9.99M
    memcpy(&x, ptr, 8);
39
9.99M
    return le64toh_internal(x);
40
9.99M
}
41
42
template <ByteType B>
43
inline void WriteLE16(B* ptr, uint16_t x)
44
0
{
45
0
    uint16_t v = htole16_internal(x);
46
0
    memcpy(ptr, &v, 2);
47
0
}
48
49
template <ByteType B>
50
inline void WriteLE32(B* ptr, uint32_t x)
51
235M
{
52
235M
    uint32_t v = htole32_internal(x);
53
235M
    memcpy(ptr, &v, 4);
54
235M
}
_Z9WriteLE32ITk8ByteTypehEvPT_j
Line
Count
Source
51
311k
{
52
311k
    uint32_t v = htole32_internal(x);
53
311k
    memcpy(ptr, &v, 4);
54
311k
}
_Z9WriteLE32ITk8ByteTypeSt4byteEvPT_j
Line
Count
Source
51
234M
{
52
234M
    uint32_t v = htole32_internal(x);
53
234M
    memcpy(ptr, &v, 4);
54
234M
}
55
56
template <ByteType B>
57
inline void WriteLE64(B* ptr, uint64_t x)
58
1.10k
{
59
1.10k
    uint64_t v = htole64_internal(x);
60
1.10k
    memcpy(ptr, &v, 8);
61
1.10k
}
Unexecuted instantiation: _Z9WriteLE64ITk8ByteTypeSt4byteEvPT_y
_Z9WriteLE64ITk8ByteTypehEvPT_y
Line
Count
Source
58
1.10k
{
59
1.10k
    uint64_t v = htole64_internal(x);
60
1.10k
    memcpy(ptr, &v, 8);
61
1.10k
}
62
63
template <ByteType B>
64
inline uint16_t ReadBE16(const B* ptr)
65
20.0k
{
66
20.0k
    uint16_t x;
67
20.0k
    memcpy(&x, ptr, 2);
68
20.0k
    return be16toh_internal(x);
69
20.0k
}
70
71
template <ByteType B>
72
inline uint32_t ReadBE32(const B* ptr)
73
213k
{
74
213k
    uint32_t x;
75
213k
    memcpy(&x, ptr, 4);
76
213k
    return be32toh_internal(x);
77
213k
}
_Z8ReadBE32ITk8ByteTypehEjPKT_
Line
Count
Source
73
213k
{
74
213k
    uint32_t x;
75
213k
    memcpy(&x, ptr, 4);
76
213k
    return be32toh_internal(x);
77
213k
}
Unexecuted instantiation: _Z8ReadBE32ITk8ByteTypeSt4byteEjPKT_
78
79
template <ByteType B>
80
inline uint64_t ReadBE64(const B* ptr)
81
156M
{
82
156M
    uint64_t x;
83
156M
    memcpy(&x, ptr, 8);
84
156M
    return be64toh_internal(x);
85
156M
}
86
87
template <ByteType B>
88
inline void WriteBE16(B* ptr, uint16_t x)
89
0
{
90
0
    uint16_t v = htobe16_internal(x);
91
0
    memcpy(ptr, &v, 2);
92
0
}
93
94
template <ByteType B>
95
inline void WriteBE32(B* ptr, uint32_t x)
96
1.13G
{
97
1.13G
    uint32_t v = htobe32_internal(x);
98
1.13G
    memcpy(ptr, &v, 4);
99
1.13G
}
100
101
template <ByteType B>
102
inline void WriteBE64(B* ptr, uint64_t x)
103
224M
{
104
224M
    uint64_t v = htobe64_internal(x);
105
224M
    memcpy(ptr, &v, 8);
106
224M
}
107
108
#endif // BITCOIN_CRYPTO_COMMON_H