Skip to content

Commit 349a46a

Browse files
cleanup
1 parent 88261ab commit 349a46a

3 files changed

Lines changed: 221 additions & 238 deletions

File tree

libcanard/canard.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static tx_frame_t* tx_frame_new(canard_t* const self, const size_t data_size)
448448
if (frame != NULL) {
449449
frame->next = NULL;
450450
frame->refcount = 1U;
451-
frame->dlc = canard_len_to_dlc[data_size]; // NOLINT(*-security.ArrayBound)
451+
frame->dlc = canard_len_to_dlc[data_size] & 15U; // NOLINT(*-security.ArrayBound)
452452
// Update the count; this is decremented when the frame is freed upon refcount reaching zero.
453453
self->tx.queue_size++;
454454
}
@@ -968,7 +968,7 @@ static bool tx_push(canard_t* const self,
968968
CANARD_ASSERT((self->tx.queue_size - queue_size_before) == n_frames);
969969
CANARD_ASSERT(self->tx.queue_size <= self->tx.queue_capacity);
970970
(void)queue_size_before;
971-
const size_t frame_refcount_inc = popcount(tr->iface_bitmap) - 1U;
971+
const byte_t frame_refcount_inc = (byte_t)(popcount(tr->iface_bitmap) - 1U);
972972
CANARD_ASSERT(frame_refcount_inc < CANARD_IFACE_COUNT);
973973
if (frame_refcount_inc > 0) {
974974
tx_frame_t* frame = spool;

libcanard/canard.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ typedef enum canard_prio_t
144144
#ifndef CANARD_TX_SHARDING_BITS
145145
#define CANARD_TX_SHARDING_BITS 4U
146146
#endif
147-
#if (CANARD_TX_SHARDING_BITS < 3) || (CANARD_TX_SHARDING_BITS > 16)
148-
#error "CANARD_TX_SHARDING_BITS must be in the range [3, 16]"
147+
#if (CANARD_TX_SHARDING_BITS < 3)
148+
#error "CANARD_TX_SHARDING_BITS must be at least 3"
149149
#endif
150150
#define CANARD_TX_SHARDS (1U << CANARD_TX_SHARDING_BITS)
151151

@@ -411,7 +411,7 @@ struct canard_t
411411
///
412412
/// Unlike Cyphal/UDP, we don't have a dedicated deadline index, again to conserve memory. Instead, we do
413413
/// iterative scanning during poll() by storing the iteration cursors here. They are invalidated as needed.
414-
uint16_t pending_shards_bitmap[CANARD_IFACE_COUNT]; ///< Bit index corresponds to non-empty pending shards.
414+
uint32_t pending_shards_bitmap[CANARD_IFACE_COUNT]; ///< Bit index corresponds to non-empty pending shards.
415415
canard_list_t pending[CANARD_TX_SHARDS][CANARD_IFACE_COUNT]; ///< Next to transmit at the head.
416416
canard_list_t delayed[CANARD_TX_SHARDS]; ///< Soonest retry time at the head. HEAT_DEATH if backlogged, at tail.
417417
canard_list_t oldest[2]; ///< ALL transfers, oldest at head, sharded by QoS (1=reliable).

0 commit comments

Comments
 (0)