Skip to content

Commit 0319d2e

Browse files
udpard_rx_new does not need to return anything now
1 parent a598ee8 commit 0319d2e

File tree

5 files changed

+24
-28
lines changed

5 files changed

+24
-28
lines changed

libudpard/udpard.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,19 +1507,16 @@ static bool rx_validate_mem_resources(const udpard_rx_mem_resources_t memory)
15071507
(memory.fragment.alloc != NULL) && (memory.fragment.free != NULL);
15081508
}
15091509

1510-
bool udpard_rx_new(udpard_rx_t* const self)
1511-
{
1512-
const bool ok = (self != NULL);
1513-
if (ok) {
1514-
mem_zero(sizeof(*self), self);
1515-
self->list_session_by_animation = (udpard_list_t){ NULL, NULL };
1516-
self->index_session_by_reordering = NULL;
1517-
self->errors_oom = 0;
1518-
self->errors_frame_malformed = 0;
1519-
self->errors_transfer_malformed = 0;
1520-
self->user = NULL;
1521-
}
1522-
return ok;
1510+
void udpard_rx_new(udpard_rx_t* const self)
1511+
{
1512+
UDPARD_ASSERT(self != NULL);
1513+
mem_zero(sizeof(*self), self);
1514+
self->list_session_by_animation = (udpard_list_t){ NULL, NULL };
1515+
self->index_session_by_reordering = NULL;
1516+
self->errors_oom = 0;
1517+
self->errors_frame_malformed = 0;
1518+
self->errors_transfer_malformed = 0;
1519+
self->user = NULL;
15231520
}
15241521

15251522
void udpard_rx_poll(udpard_rx_t* const self, const udpard_us_t now)

libudpard/udpard.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,8 @@ struct udpard_rx_ack_mandate_t
698698
};
699699

700700
/// The RX instance holds no resources and can be destroyed at any time by simply freeing all its ports first
701-
/// using udpard_rx_port_free(), then discarding the instance itself.
702-
/// True on success, false if any of the arguments are invalid.
703-
bool udpard_rx_new(udpard_rx_t* const self);
701+
/// using udpard_rx_port_free(), then discarding the instance itself. The self pointer must not be NULL.
702+
void udpard_rx_new(udpard_rx_t* const self);
704703

705704
/// Must be invoked at least every few milliseconds (more often is fine) to purge timed-out sessions and eject
706705
/// received transfers when the reordering window expires. If this is invoked simultaneously with rx subscription

tests/src/test_e2e_edge.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct Fixture
6262
dest = udpard_make_subject_endpoint(222U);
6363

6464
TEST_ASSERT_TRUE(udpard_tx_new(&tx, 0x0A0B0C0D0E0F1011ULL, 16, tx_mem));
65-
TEST_ASSERT_TRUE(udpard_rx_new(&rx));
65+
udpard_rx_new(&rx);
6666
ctx.expected_uid = tx.local_uid;
6767
ctx.source = source;
6868
rx.user = &ctx;

tests/src/test_e2e_random.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void test_udpard_tx_rx_end_to_end()
156156
const udpard_rx_mem_resources_t rx_mem{ .session = instrumented_allocator_make_resource(&rx_alloc_session),
157157
.fragment = instrumented_allocator_make_resource(&rx_alloc_frag) };
158158
udpard_rx_t rx;
159-
TEST_ASSERT_TRUE(udpard_rx_new(&rx));
159+
udpard_rx_new(&rx);
160160

161161
// Test parameters.
162162
constexpr std::array<uint64_t, 3> topic_hashes{ 0x123456789ABCDEF0ULL,

tests/src/test_intrusive_rx.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,7 @@ static void test_rx_session_ordered(void)
16621662

16631663
// Initialize the shared RX instance.
16641664
udpard_rx_t rx;
1665-
TEST_ASSERT(udpard_rx_new(&rx));
1665+
udpard_rx_new(&rx);
16661666
callback_result_t cb_result = { 0 };
16671667
rx.user = &cb_result;
16681668

@@ -2274,7 +2274,7 @@ static void test_rx_session_unordered(void)
22742274

22752275
// Initialize the shared RX instance.
22762276
udpard_rx_t rx;
2277-
TEST_ASSERT(udpard_rx_new(&rx));
2277+
udpard_rx_new(&rx);
22782278
callback_result_t cb_result = { 0 };
22792279
rx.user = &cb_result;
22802280

@@ -2515,7 +2515,7 @@ static void test_rx_session_unordered_reject_old(void)
25152515
const udpard_rx_mem_resources_t rx_mem = { .fragment = mem_frag, .session = mem_session };
25162516
udpard_rx_t rx;
25172517
callback_result_t cb_result = { 0 };
2518-
TEST_ASSERT(udpard_rx_new(&rx));
2518+
udpard_rx_new(&rx);
25192519
rx.user = &cb_result;
25202520
const uint64_t local_uid = 0xF00DCAFEF00DCAFEULL;
25212521
udpard_rx_port_t port;
@@ -2613,7 +2613,7 @@ static void test_rx_session_unordered_duplicates(void)
26132613
const udpard_rx_mem_resources_t rx_mem = { .fragment = mem_frag, .session = mem_session };
26142614
udpard_rx_t rx;
26152615
callback_result_t cb_result = { 0 };
2616-
TEST_ASSERT(udpard_rx_new(&rx));
2616+
udpard_rx_new(&rx);
26172617
rx.user = &cb_result;
26182618
udpard_rx_port_t port;
26192619
const uint64_t topic_hash = 0x1111222233334444ULL;
@@ -2685,7 +2685,7 @@ static void test_rx_session_ordered_reject_stale_after_jump(void)
26852685
const udpard_mem_deleter_t del_payload = instrumented_allocator_make_deleter(&alloc_payload);
26862686
const udpard_rx_mem_resources_t rx_mem = { .fragment = mem_frag, .session = mem_session };
26872687
udpard_rx_t rx;
2688-
TEST_ASSERT(udpard_rx_new(&rx));
2688+
udpard_rx_new(&rx);
26892689
callback_result_t cb_result = { 0 };
26902690
rx.user = &cb_result;
26912691
udpard_rx_port_t port;
@@ -2807,7 +2807,7 @@ static void test_rx_session_ordered_zero_reordering_window(void)
28072807
const udpard_rx_mem_resources_t rx_mem = { .fragment = mem_frag, .session = mem_session };
28082808
udpard_rx_t rx;
28092809
callback_result_t cb_result = { 0 };
2810-
TEST_ASSERT(udpard_rx_new(&rx));
2810+
udpard_rx_new(&rx);
28112811
rx.user = &cb_result;
28122812
udpard_rx_port_t port;
28132813
const uint64_t topic_hash = 0x9999888877776666ULL;
@@ -2885,7 +2885,7 @@ static void test_rx_port(void)
28852885

28862886
// Initialize the shared RX instance.
28872887
udpard_rx_t rx;
2888-
TEST_ASSERT(udpard_rx_new(&rx));
2888+
udpard_rx_new(&rx);
28892889
callback_result_t cb_result = { 0 };
28902890
rx.user = &cb_result;
28912891

@@ -3255,7 +3255,7 @@ static void test_rx_port_timeouts(void)
32553255

32563256
udpard_rx_t rx;
32573257
callback_result_t cb_result = { 0 };
3258-
TEST_ASSERT(udpard_rx_new(&rx));
3258+
udpard_rx_new(&rx);
32593259
rx.user = &cb_result;
32603260

32613261
udpard_rx_port_t port_a;
@@ -3419,7 +3419,7 @@ static void test_rx_port_oom(void)
34193419
const udpard_rx_mem_resources_t rx_mem = { .fragment = mem_frag, .session = mem_session };
34203420
udpard_rx_t rx;
34213421
callback_result_t cb_result = { 0 };
3422-
TEST_ASSERT(udpard_rx_new(&rx));
3422+
udpard_rx_new(&rx);
34233423
rx.user = &cb_result;
34243424
udpard_rx_port_t port_ordered;
34253425
udpard_rx_port_t port_stateless;
@@ -3507,7 +3507,7 @@ static void test_rx_port_free_loop(void)
35073507
const uint64_t local_uid = 0xCAFED00DCAFED00DULL;
35083508
udpard_rx_t rx;
35093509
callback_result_t cb_result = { 0 };
3510-
TEST_ASSERT(udpard_rx_new(&rx));
3510+
udpard_rx_new(&rx);
35113511
rx.user = &cb_result;
35123512

35133513
udpard_rx_port_t port_p2p;

0 commit comments

Comments
 (0)