Skip to content

Commit 1752b61

Browse files
nits
1 parent cdd62d7 commit 1752b61

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

libudpard/udpard.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ static tx_frame_t* tx_spool(udpard_tx_t* const tx,
824824
static udpard_us_t tx_ack_timeout(const udpard_us_t baseline, const udpard_prio_t prio, const size_t attempts)
825825
{
826826
UDPARD_ASSERT(baseline > 0);
827-
UDPARD_ASSERT(prio <= UDPARD_PRIORITY_MAX);
827+
UDPARD_ASSERT(prio < UDPARD_PRIORITY_COUNT);
828828
return baseline * (1LL << smaller((size_t)prio + attempts, 62)); // NOLINT(*-signed-bitwise)
829829
}
830830

@@ -1145,7 +1145,7 @@ uint32_t udpard_tx_push(udpard_tx_t* const self,
11451145
{
11461146
uint32_t out = 0;
11471147
const bool ok = (self != NULL) && (deadline >= now) && (now >= 0) && (self->local_uid != 0) &&
1148-
(valid_ep_mask(remote_ep) != 0) && (priority <= UDPARD_PRIORITY_MAX) &&
1148+
(valid_ep_mask(remote_ep) != 0) && (priority < UDPARD_PRIORITY_COUNT) &&
11491149
((payload.bytes.data != NULL) || (payload.bytes.size == 0U)) &&
11501150
(tx_transfer_find(self, topic_hash, transfer_id) == NULL);
11511151
if (ok) {
@@ -1176,7 +1176,7 @@ uint32_t udpard_tx_push_p2p(udpard_tx_t* const self,
11761176
{
11771177
uint32_t out = 0;
11781178
const bool ok = (self != NULL) && (deadline >= now) && (now >= 0) && (self->local_uid != 0) &&
1179-
(valid_ep_mask(remote.endpoints) != 0) && (priority <= UDPARD_PRIORITY_MAX) &&
1179+
(valid_ep_mask(remote.endpoints) != 0) && (priority < UDPARD_PRIORITY_COUNT) &&
11801180
((payload.bytes.data != NULL) || (payload.bytes.size == 0U));
11811181
if (ok) {
11821182
udpard_tx_poll(self, now, UDPARD_IFACE_MASK_ALL);

libudpard/udpard.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ extern "C"
6161
#define UDPARD_VERSION_MINOR 0
6262

6363
/// The version number of the Cyphal specification implemented by this library.
64-
#define UDPARD_CYPHAL_SPECIFICATION_VERSION_MAJOR 1
65-
#define UDPARD_CYPHAL_SPECIFICATION_VERSION_MINOR 1
64+
#define UDPARD_CYPHAL_VERSION_MAJOR 1
65+
#define UDPARD_CYPHAL_VERSION_MINOR 1
6666

6767
/// RFC 791 states that hosts must be prepared to accept datagrams of up to 576 octets and it is expected that this
6868
/// library will receive non IP-fragmented datagrams thus the minimum MTU should be larger than 576.
@@ -106,9 +106,6 @@ typedef int64_t udpard_us_t;
106106
/// In IPv6 networks, 32 bits are supported.
107107
#define UDPARD_IPv4_SUBJECT_ID_MAX 0x7FFFFFUL
108108

109-
#define UDPARD_PRIORITY_MAX 7U
110-
#define UDPARD_PRIORITY_COUNT (UDPARD_PRIORITY_MAX + 1U)
111-
112109
typedef enum udpard_prio_t
113110
{
114111
udpard_prio_exceptional = 0,
@@ -120,6 +117,7 @@ typedef enum udpard_prio_t
120117
udpard_prio_slow = 6,
121118
udpard_prio_optional = 7,
122119
} udpard_prio_t;
120+
#define UDPARD_PRIORITY_COUNT 8U
123121

124122
typedef struct udpard_tree_t
125123
{

tests/src/helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#error "Library version not defined"
1818
#endif
1919

20-
#if !(defined(UDPARD_CYPHAL_SPECIFICATION_VERSION_MAJOR) && defined(UDPARD_CYPHAL_SPECIFICATION_VERSION_MINOR))
20+
#if !(defined(UDPARD_CYPHAL_VERSION_MAJOR) && defined(UDPARD_CYPHAL_VERSION_MINOR))
2121
#error "Cyphal specification version not defined"
2222
#endif
2323

0 commit comments

Comments
 (0)