Skip to content

Commit e42f628

Browse files
fix
1 parent 71c53f2 commit e42f628

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

libudpard/udpard.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,11 +1676,11 @@ static void rx_port_accept_stateful(udpard_rx_t* const rx,
16761676
.now = timestamp,
16771677
};
16781678
rx_session_t* const ses = // Will find an existing one or create a new one.
1679-
(rx_session_t*)cavl2_find_or_insert(&port->index_session_by_remote_uid,
1680-
&frame.meta.sender_uid,
1681-
&cavl_compare_rx_session_by_remote_uid,
1682-
&fac_args,
1683-
&cavl_factory_rx_session_by_remote_uid);
1679+
(rx_session_t*)(void*)cavl2_find_or_insert(&port->index_session_by_remote_uid,
1680+
&frame.meta.sender_uid,
1681+
&cavl_compare_rx_session_by_remote_uid,
1682+
&fac_args,
1683+
&cavl_factory_rx_session_by_remote_uid);
16841684
if (ses != NULL) {
16851685
rx_session_update(ses, rx, timestamp, source_ep, frame, payload_deleter, redundant_iface_index);
16861686
} else {

libudpard/udpard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ typedef struct udpard_rx_t
707707

708708
uint64_t errors_oom; ///< A frame could not be processed (transfer possibly dropped) due to OOM.
709709
uint64_t errors_frame_malformed; ///< A received frame was malformed and thus dropped.
710-
uint64_t errors_transfer_malformed; ///< A received transfer was malformed (e.g., CRC error) and thus dropped.
710+
uint64_t errors_transfer_malformed; ///< A transfer could not be reassembled correctly.
711711

712712
void* user; ///< Opaque pointer for the application use only. Not accessed by the library.
713713
} udpard_rx_t;

tests/src/test_public.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ void test_udpard_fragment_gather()
166166
const udpard_mem_deleter_t del_payload = instrumented_allocator_make_deleter(&alloc_payload);
167167

168168
// Test 1: NULL fragment returns 0.
169-
char buf[100]; // NOLINT(*-avoid-c-arrays)
169+
char buf[100]; // NOLINT(*-avoid-c-arrays)
170170
TEST_ASSERT_EQUAL_size_t(0, udpard_fragment_gather(nullptr, sizeof(buf), static_cast<void*>(buf)));
171171

172172
// Test 2: NULL destination returns 0.
173-
udpard_fragment_t* single = make_test_fragment(mem_frag, mem_payload, del_payload, 0, 5, "hello");
173+
udpard_fragment_t* const single = make_test_fragment(mem_frag, mem_payload, del_payload, 0, 5, "hello");
174174
TEST_ASSERT_NOT_NULL(single);
175175
single->index_offset.up = nullptr;
176176
single->index_offset.lr[0] = nullptr;
@@ -179,12 +179,12 @@ void test_udpard_fragment_gather()
179179
TEST_ASSERT_EQUAL_size_t(0, udpard_fragment_gather(single, sizeof(buf), nullptr));
180180

181181
// Test 3: Single fragment - gather all.
182-
(void) std::memset(static_cast<void*>(buf), 0, sizeof(buf));
182+
(void)std::memset(static_cast<void*>(buf), 0, sizeof(buf));
183183
TEST_ASSERT_EQUAL_size_t(5, udpard_fragment_gather(single, sizeof(buf), static_cast<void*>(buf)));
184184
TEST_ASSERT_EQUAL_MEMORY("hello", buf, 5);
185185

186186
// Test 4: Single fragment - truncation (destination smaller than fragment).
187-
(void) std::memset(static_cast<void*>(buf), 0, sizeof(buf));
187+
(void)std::memset(static_cast<void*>(buf), 0, sizeof(buf));
188188
TEST_ASSERT_EQUAL_size_t(3, udpard_fragment_gather(single, 3, static_cast<void*>(buf)));
189189
TEST_ASSERT_EQUAL_MEMORY("hel", buf, 3);
190190

@@ -193,11 +193,11 @@ void test_udpard_fragment_gather()
193193
mem_frag.free(mem_frag.user, sizeof(udpard_fragment_t), single);
194194

195195
// Test 5: Multiple fragments forming a tree.
196-
// Create tree: root at offset 5 ("MID"), left at offset 0 ("ABCDE"), right at offset 10 ("WXYZ")
196+
// Create tree: root at offset 5 ("MID"), left at offset 0 ("ABCDE"), right at offset 8 ("WXYZ")
197197
// Total payload when gathered: "ABCDE" + "MID" + "WXYZ" = "ABCDEMIDWXYZ" (12 bytes)
198-
udpard_fragment_t* root = make_test_fragment(mem_frag, mem_payload, del_payload, 5, 3, "MID");
199-
udpard_fragment_t* left = make_test_fragment(mem_frag, mem_payload, del_payload, 0, 5, "ABCDE");
200-
udpard_fragment_t* right = make_test_fragment(mem_frag, mem_payload, del_payload, 10, 4, "WXYZ");
198+
udpard_fragment_t* const root = make_test_fragment(mem_frag, mem_payload, del_payload, 5, 3, "MID");
199+
udpard_fragment_t* const left = make_test_fragment(mem_frag, mem_payload, del_payload, 0, 5, "ABCDE");
200+
udpard_fragment_t* const right = make_test_fragment(mem_frag, mem_payload, del_payload, 8, 4, "WXYZ");
201201
TEST_ASSERT_NOT_NULL(root);
202202
TEST_ASSERT_NOT_NULL(left);
203203
TEST_ASSERT_NOT_NULL(right);
@@ -219,27 +219,27 @@ void test_udpard_fragment_gather()
219219
right->index_offset.bf = 0;
220220

221221
// Gather from root - should collect all fragments in order.
222-
(void) std::memset(static_cast<void*>(buf), 0, sizeof(buf));
222+
(void)std::memset(static_cast<void*>(buf), 0, sizeof(buf));
223223
TEST_ASSERT_EQUAL_size_t(12, udpard_fragment_gather(root, sizeof(buf), static_cast<void*>(buf)));
224224
TEST_ASSERT_EQUAL_MEMORY("ABCDEMIDWXYZ", buf, 12);
225225

226226
// Gather from left child - should still collect all fragments (traverses to root first).
227-
(void) std::memset(static_cast<void*>(buf), 0, sizeof(buf));
227+
(void)std::memset(static_cast<void*>(buf), 0, sizeof(buf));
228228
TEST_ASSERT_EQUAL_size_t(12, udpard_fragment_gather(left, sizeof(buf), static_cast<void*>(buf)));
229229
TEST_ASSERT_EQUAL_MEMORY("ABCDEMIDWXYZ", buf, 12);
230230

231231
// Gather from right child - should still collect all fragments.
232-
(void) std::memset(static_cast<void*>(buf), 0, sizeof(buf));
232+
(void)std::memset(static_cast<void*>(buf), 0, sizeof(buf));
233233
TEST_ASSERT_EQUAL_size_t(12, udpard_fragment_gather(right, sizeof(buf), static_cast<void*>(buf)));
234234
TEST_ASSERT_EQUAL_MEMORY("ABCDEMIDWXYZ", buf, 12);
235235

236236
// Test 6: Truncation with multiple fragments - buffer smaller than total.
237-
(void) std::memset(static_cast<void*>(buf), 0, sizeof(buf));
237+
(void)std::memset(static_cast<void*>(buf), 0, sizeof(buf));
238238
TEST_ASSERT_EQUAL_size_t(7, udpard_fragment_gather(root, 7, static_cast<void*>(buf)));
239239
TEST_ASSERT_EQUAL_MEMORY("ABCDEMI", buf, 7);
240240

241241
// Test 7: Truncation mid-fragment.
242-
(void) std::memset(static_cast<void*>(buf), 0, sizeof(buf));
242+
(void)std::memset(static_cast<void*>(buf), 0, sizeof(buf));
243243
TEST_ASSERT_EQUAL_size_t(3, udpard_fragment_gather(root, 3, static_cast<void*>(buf)));
244244
TEST_ASSERT_EQUAL_MEMORY("ABC", buf, 3);
245245

0 commit comments

Comments
 (0)