@@ -79,7 +79,6 @@ typedef uint16_t TransferCRC;
7979#define CRC_INITIAL 0xFFFFU
8080#define CRC_RESIDUE 0x0000U
8181#define CRC_SIZE_BYTES 2U
82- #define PORT_ID_MINIMUM 49152
8382
8483#if (CANARD_CRC_TABLE != 0 )
8584static const uint16_t CRCTable [256 ] = {
@@ -1383,12 +1382,11 @@ int8_t canardRxSubscribe(struct CanardInstance* const ins,
13831382 const CanardMicrosecond transfer_id_timeout_usec ,
13841383 struct CanardRxSubscription * const out_subscription )
13851384{
1386- int8_t out = - CANARD_ERROR_INVALID_ARGUMENT ;
1387- const size_t tk = (size_t ) transfer_kind ;
1388-
1389- if ((ins != NULL ) && (out_subscription != NULL ) && (tk < CANARD_NUM_TRANSFER_KINDS ) &&
1390- (((transfer_kind == CanardTransferKindMessage ) && (port_id <= CANARD_SUBJECT_ID_MAX )) ||
1391- (port_id <= CANARD_SERVICE_ID_MAX )))
1385+ int8_t out = - CANARD_ERROR_INVALID_ARGUMENT ;
1386+ const size_t tk = (size_t ) transfer_kind ;
1387+ const bool port_id_ok = ((transfer_kind == CanardTransferKindMessage ) && (port_id <= CANARD_SUBJECT_ID_MAX )) ||
1388+ (port_id <= CANARD_SERVICE_ID_MAX );
1389+ if ((ins != NULL ) && (out_subscription != NULL ) && (tk < CANARD_NUM_TRANSFER_KINDS ) && port_id_ok )
13921390 {
13931391 // Reset to the initial state. This is absolutely critical because the new payload size limit may be larger
13941392 // than the old value; if there are any payload buffers allocated, we may overrun them because they are shorter
0 commit comments