diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index f7491c6390..07d1bc253e 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -1717,11 +1717,11 @@ int32_t FreeRTOS_add_int32( int32_t a, { int32_t ret; - if( ( a > 0 ) && ( b > ipINT32_MAX_VALUE - a ) ) + if( ( a > 0 ) && ( b > ( ipINT32_MAX_VALUE - a ) ) ) { ret = ipINT32_MAX_VALUE; /* Positive overflow */ } - else if( ( a < 0 ) && ( b < ipINT32_MIN_VALUE - a ) ) + else if( ( a < 0 ) && ( b < ( ipINT32_MIN_VALUE - a ) ) ) { ret = ipINT32_MIN_VALUE; /* Negative underflow */ } @@ -1748,11 +1748,11 @@ int32_t FreeRTOS_multiply_int32( int32_t a, /* Check for overflow/underflow */ if( a > 0 ) { - if( ( b > 0 ) && ( a > ipINT32_MAX_VALUE / b ) ) + if( ( b > 0 ) && ( a > ( ipINT32_MAX_VALUE / b ) ) ) { ret = ipINT32_MAX_VALUE; /* Positive overflow */ } - else if( ( b < 0 ) && ( b < ipINT32_MIN_VALUE / a ) ) + else if( ( b < 0 ) && ( b < ( ipINT32_MIN_VALUE / a ) ) ) { ret = ipINT32_MIN_VALUE; /* Negative underflow */ } @@ -1763,11 +1763,11 @@ int32_t FreeRTOS_multiply_int32( int32_t a, } else { - if( ( b > 0 ) && ( a < ipINT32_MIN_VALUE / b ) ) + if( ( b > 0 ) && ( a < ( ipINT32_MIN_VALUE / b ) ) ) { ret = ipINT32_MIN_VALUE; /* Negative underflow */ } - else if( ( b < 0 ) && ( a < ipINT32_MAX_VALUE / b ) ) + else if( ( b < 0 ) && ( a < ( ipINT32_MAX_VALUE / b ) ) ) { ret = ipINT32_MAX_VALUE; /* Positive overflow */ } diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index 62d100ed66..476c2a4c6e 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -99,6 +99,9 @@ /** @brief The time at which the last unsolicited ND was sent. Unsolicited NDs are used * to ensure ND tables are up to date and to detect IP address conflicts. */ +/* MISRA Ref 8.9.1 [File scoped variables] */ +/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-89 */ +/* coverity[misra_c_2012_rule_8_9_violation] */ static TickType_t xLastUnsolicitedNDTime = 0U; /*-----------------------------------------------------------*/ diff --git a/source/FreeRTOS_TCP_WIN.c b/source/FreeRTOS_TCP_WIN.c index 87f4488b2c..303fd22ea3 100644 --- a/source/FreeRTOS_TCP_WIN.c +++ b/source/FreeRTOS_TCP_WIN.c @@ -1905,7 +1905,7 @@ int32_t lWeight = 0; int32_t lDivisor = 0; - mS = mS < 0 ? ipINT32_MAX_VALUE : mS; + mS = ( mS < 0 ) ? ipINT32_MAX_VALUE : mS; if( pxWindow->lSRTT >= mS ) { diff --git a/source/include/FreeRTOS_IP.h b/source/include/FreeRTOS_IP.h index ecd12a1c94..bb99f5c124 100644 --- a/source/include/FreeRTOS_IP.h +++ b/source/include/FreeRTOS_IP.h @@ -61,10 +61,10 @@ #define ipSIZE_OF_TCP_HEADER 20U /* The maximum of int32 value. */ -#define ipINT32_MAX_VALUE ( ( int32_t ) 0x7FFFFFFF ) +#define ipINT32_MAX_VALUE ( ( int32_t ) 0x7FFFFFFFU ) /* The minimum of int32 value. */ -#define ipINT32_MIN_VALUE ( ( int32_t ) 0x80000000 ) +#define ipINT32_MIN_VALUE ( ( int32_t ) 0x80000000U ) /* * Generate a randomized TCP Initial Sequence Number per RFC.