Skip to content

Commit c3bc669

Browse files
unused functions
1 parent 7859378 commit c3bc669

4 files changed

Lines changed: 2 additions & 89 deletions

File tree

libcanard/canard.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ static byte_t popcount_emulated(uint64_t x)
106106

107107
static byte_t popcount(const uint64_t x)
108108
{
109+
(void)popcount_emulated; // Avoid unused function warning if intrinsics are available.
109110
#ifdef stdc_count_ones
110111
return (byte_t)stdc_count_ones(x); // C23 feature
111112
#elif defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)

tests/src/test_api_roundtrip.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,6 @@
1515
// Infrastructure
1616
// =====================================================================================================================
1717

18-
// CRC-16/CCITT-FALSE used by Cyphal v1 multi-frame transfers.
19-
// clang-format off
20-
static const uint16_t crc_lut[256] = {
21-
0x0000U, 0x1021U, 0x2042U, 0x3063U, 0x4084U, 0x50A5U, 0x60C6U, 0x70E7U,
22-
0x8108U, 0x9129U, 0xA14AU, 0xB16BU, 0xC18CU, 0xD1ADU, 0xE1CEU, 0xF1EFU,
23-
0x1231U, 0x0210U, 0x3273U, 0x2252U, 0x52B5U, 0x4294U, 0x72F7U, 0x62D6U,
24-
0x9339U, 0x8318U, 0xB37BU, 0xA35AU, 0xD3BDU, 0xC39CU, 0xF3FFU, 0xE3DEU,
25-
0x2462U, 0x3443U, 0x0420U, 0x1401U, 0x64E6U, 0x74C7U, 0x44A4U, 0x5485U,
26-
0xA56AU, 0xB54BU, 0x8528U, 0x9509U, 0xE5EEU, 0xF5CFU, 0xC5ACU, 0xD58DU,
27-
0x3653U, 0x2672U, 0x1611U, 0x0630U, 0x76D7U, 0x66F6U, 0x5695U, 0x46B4U,
28-
0xB75BU, 0xA77AU, 0x9719U, 0x8738U, 0xF7DFU, 0xE7FEU, 0xD79DU, 0xC7BCU,
29-
0x48C4U, 0x58E5U, 0x6886U, 0x78A7U, 0x0840U, 0x1861U, 0x2802U, 0x3823U,
30-
0xC9CCU, 0xD9EDU, 0xE98EU, 0xF9AFU, 0x8948U, 0x9969U, 0xA90AU, 0xB92BU,
31-
0x5AF5U, 0x4AD4U, 0x7AB7U, 0x6A96U, 0x1A71U, 0x0A50U, 0x3A33U, 0x2A12U,
32-
0xDBFDU, 0xCBDCU, 0xFBBFU, 0xEB9EU, 0x9B79U, 0x8B58U, 0xBB3BU, 0xAB1AU,
33-
0x6CA6U, 0x7C87U, 0x4CE4U, 0x5CC5U, 0x2C22U, 0x3C03U, 0x0C60U, 0x1C41U,
34-
0xEDAEU, 0xFD8FU, 0xCDECU, 0xDDCDU, 0xAD2AU, 0xBD0BU, 0x8D68U, 0x9D49U,
35-
0x7E97U, 0x6EB6U, 0x5ED5U, 0x4EF4U, 0x3E13U, 0x2E32U, 0x1E51U, 0x0E70U,
36-
0xFF9FU, 0xEFBEU, 0xDFDDU, 0xCFFCU, 0xBF1BU, 0xAF3AU, 0x9F59U, 0x8F78U,
37-
0x9188U, 0x81A9U, 0xB1CAU, 0xA1EBU, 0xD10CU, 0xC12DU, 0xF14EU, 0xE16FU,
38-
0x1080U, 0x00A1U, 0x30C2U, 0x20E3U, 0x5004U, 0x4025U, 0x7046U, 0x6067U,
39-
0x83B9U, 0x9398U, 0xA3FBU, 0xB3DAU, 0xC33DU, 0xD31CU, 0xE37FU, 0xF35EU,
40-
0x02B1U, 0x1290U, 0x22F3U, 0x32D2U, 0x4235U, 0x5214U, 0x6277U, 0x7256U,
41-
0xB5EAU, 0xA5CBU, 0x95A8U, 0x8589U, 0xF56EU, 0xE54FU, 0xD52CU, 0xC50DU,
42-
0x34E2U, 0x24C3U, 0x14A0U, 0x0481U, 0x7466U, 0x6447U, 0x5424U, 0x4405U,
43-
0xA7DBU, 0xB7FAU, 0x8799U, 0x97B8U, 0xE75FU, 0xF77EU, 0xC71DU, 0xD73CU,
44-
0x26D3U, 0x36F2U, 0x0691U, 0x16B0U, 0x6657U, 0x7676U, 0x4615U, 0x5634U,
45-
0xD94CU, 0xC96DU, 0xF90EU, 0xE92FU, 0x99C8U, 0x89E9U, 0xB98AU, 0xA9ABU,
46-
0x5844U, 0x4865U, 0x7806U, 0x6827U, 0x18C0U, 0x08E1U, 0x3882U, 0x28A3U,
47-
0xCB7DU, 0xDB5CU, 0xEB3FU, 0xFB1EU, 0x8BF9U, 0x9BD8U, 0xABBBU, 0xBB9AU,
48-
0x4A75U, 0x5A54U, 0x6A37U, 0x7A16U, 0x0AF1U, 0x1AD0U, 0x2AB3U, 0x3A92U,
49-
0xFD2EU, 0xED0FU, 0xDD6CU, 0xCD4DU, 0xBDAAU, 0xAD8BU, 0x9DE8U, 0x8DC9U,
50-
0x7C26U, 0x6C07U, 0x5C64U, 0x4C45U, 0x3CA2U, 0x2C83U, 0x1CE0U, 0x0CC1U,
51-
0xEF1FU, 0xFF3EU, 0xCF5DU, 0xDF7CU, 0xAF9BU, 0xBFBAU, 0x8FD9U, 0x9FF8U,
52-
0x6E17U, 0x7E36U, 0x4E55U, 0x5E74U, 0x2E93U, 0x3EB2U, 0x0ED1U, 0x1EF0U,
53-
};
54-
// clang-format on
55-
56-
static uint16_t crc16_ccitt(uint16_t crc, const void* data, const size_t len)
57-
{
58-
const auto* p = static_cast<const uint_least8_t*>(data);
59-
for (size_t i = 0; i < len; i++) {
60-
crc = static_cast<uint16_t>((static_cast<unsigned>(crc) << 8U) ^
61-
crc_lut[(static_cast<unsigned>(crc) >> 8U) ^ p[i]]);
62-
}
63-
return crc;
64-
}
65-
66-
// ------------------------------------------------ Allocator --------------------------------------------------------
67-
6818
static void* std_alloc_mem(const canard_mem_t, const size_t size) { return std::malloc(size); }
6919
static void std_free_mem(const canard_mem_t, const size_t, void* const pointer) { std::free(pointer); }
7020

tests/src/test_api_rx_edge.cpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -138,32 +138,13 @@ static const canard_subscription_vtable_t capture_sub_vtable = { .on_message = c
138138

139139
// ------------------------------------------- CAN Frame Construction Helpers ----------------------------------------
140140

141-
// v1.1 message: priority[28:26] | subject_id[25:8] | bit7=1(v1.1) | src[6:0]
141+
// v1 16-bit subject-ID message: priority[28:26] | subject_id[25:8] | bit7=1(v1.1) | src[6:0]
142142
static uint32_t make_v1v1_msg_can_id(const canard_prio_t prio, const uint16_t subject_id, const uint_least8_t src)
143143
{
144144
return (static_cast<uint32_t>(prio) << 26U) | (static_cast<uint32_t>(subject_id) << 8U) | (UINT32_C(1) << 7U) |
145145
(static_cast<uint32_t>(src) & 0x7FU);
146146
}
147147

148-
// v1.0 message: priority[28:26] | 00 | subject_id[20:8] | bit7=0 | src[6:0]
149-
static uint32_t make_v1v0_msg_can_id(const canard_prio_t prio, const uint16_t subject_id, const uint_least8_t src)
150-
{
151-
return (static_cast<uint32_t>(prio) << 26U) | (static_cast<uint32_t>(subject_id) << 8U) |
152-
(static_cast<uint32_t>(src) & 0x7FU);
153-
}
154-
155-
// v1 service: priority[28:26] | bit25=1(svc) | rnr[24] | service_id[23:14] | dst[13:7] | src[6:0]
156-
static uint32_t make_v1_svc_can_id(const canard_prio_t prio,
157-
const uint16_t service_id,
158-
const bool request_not_response,
159-
const uint_least8_t dst,
160-
const uint_least8_t src)
161-
{
162-
return (static_cast<uint32_t>(prio) << 26U) | (UINT32_C(1) << 25U) |
163-
(request_not_response ? (UINT32_C(1) << 24U) : 0U) | (static_cast<uint32_t>(service_id) << 14U) |
164-
(static_cast<uint32_t>(dst) << 7U) | (static_cast<uint32_t>(src) & 0x7FU);
165-
}
166-
167148
// v0 message: priority[28:26] | data_type_id[23:8] | bit7=0 | src[6:0]
168149
static uint32_t make_v0_msg_can_id(const canard_prio_t prio, const uint16_t dtid, const uint_least8_t src)
169150
{
@@ -182,10 +163,6 @@ static uint_least8_t make_v1_tail(const bool sot, const bool eot, const bool tog
182163
}
183164

184165
// v0 tail bytes
185-
static uint_least8_t make_v0_single_tail(const uint_least8_t tid)
186-
{
187-
return static_cast<uint_least8_t>(0xC0U | (tid & 0x1FU));
188-
}
189166
static uint_least8_t make_v0_tail(const bool sot, const bool eot, const bool toggle, const uint_least8_t tid)
190167
{
191168
return static_cast<uint_least8_t>((sot ? 0x80U : 0U) | (eot ? 0x40U : 0U) | (toggle ? 0x20U : 0U) | (tid & 0x1FU));

tests/src/test_intrusive_misc.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,6 @@ static uint64_t find_seed_dense(const uint64_t zc, const bool want_purge, const
5454
return UINT64_MAX; // should never happen for small zc
5555
}
5656

57-
// For sparse bitmaps (pc <= 64), chance is NOT called. Only random(self, zc) is consumed.
58-
static uint64_t find_seed_sparse(const uint64_t zc, const uint64_t want_z)
59-
{
60-
for (uint64_t seed = 0; seed < 10000000ULL; seed++) {
61-
canard_t probe;
62-
memset(&probe, 0, sizeof(probe));
63-
probe.prng_state = seed;
64-
const uint64_t r = random(&probe, zc);
65-
if (r == want_z) {
66-
return seed;
67-
}
68-
}
69-
return UINT64_MAX;
70-
}
71-
7257
// Find a seed where chance(&self, p_reciprocal) returns the desired outcome (single call, no collision).
7358
static uint64_t find_seed_chance(const uint64_t p_reciprocal, const bool want)
7459
{

0 commit comments

Comments
 (0)