File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ typedef uint16_t TransferCRC;
8181#define CRC_INITIAL 0xFFFFU
8282#define CRC_RESIDUE 0x0000U
8383#define CRC_SIZE_BYTES 2U
84+ #define PORT_ID_MINIMUM 49152
8485
8586#if (CANARD_CRC_TABLE != 0 )
8687static const uint16_t CRCTable [256 ] = {
@@ -1387,10 +1388,9 @@ int8_t canardRxSubscribe(struct CanardInstance* const ins,
13871388 int8_t out = - CANARD_ERROR_INVALID_ARGUMENT ;
13881389 const size_t tk = (size_t ) transfer_kind ;
13891390
1390- assert (port_id >= 49152 && port_id <= 65535 );
1391- if (port_id < 49152 || port_id > 65535 )
1391+ if (port_id < PORT_ID_MINIMUM ) // port_id can't be over 65535 because it exceeds type unsigned short maximum value.
13921392 {
1393- fprintf (stderr , "Invalid port: %d. Port should be within 49152 to 65535\n" , port_id );
1393+ ( void ) fprintf (stderr , "Invalid port: %d. Port should be within 49152 to 65535\n" , port_id );
13941394 exit (EXIT_FAILURE );
13951395 }
13961396 if ((ins != NULL ) && (out_subscription != NULL ) && (tk < CANARD_NUM_TRANSFER_KINDS ))
You can’t perform that action at this time.
0 commit comments