Skip to content

Commit e3412fb

Browse files
Fix MISRA 2012 violations (#1208)
* Fix coverity issues * Fix formatting
1 parent 5f41a38 commit e3412fb

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

source/FreeRTOS_IP_Utils.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,11 +1717,11 @@ int32_t FreeRTOS_add_int32( int32_t a,
17171717
{
17181718
int32_t ret;
17191719

1720-
if( ( a > 0 ) && ( b > ipINT32_MAX_VALUE - a ) )
1720+
if( ( a > 0 ) && ( b > ( ipINT32_MAX_VALUE - a ) ) )
17211721
{
17221722
ret = ipINT32_MAX_VALUE; /* Positive overflow */
17231723
}
1724-
else if( ( a < 0 ) && ( b < ipINT32_MIN_VALUE - a ) )
1724+
else if( ( a < 0 ) && ( b < ( ipINT32_MIN_VALUE - a ) ) )
17251725
{
17261726
ret = ipINT32_MIN_VALUE; /* Negative underflow */
17271727
}
@@ -1748,11 +1748,11 @@ int32_t FreeRTOS_multiply_int32( int32_t a,
17481748
/* Check for overflow/underflow */
17491749
if( a > 0 )
17501750
{
1751-
if( ( b > 0 ) && ( a > ipINT32_MAX_VALUE / b ) )
1751+
if( ( b > 0 ) && ( a > ( ipINT32_MAX_VALUE / b ) ) )
17521752
{
17531753
ret = ipINT32_MAX_VALUE; /* Positive overflow */
17541754
}
1755-
else if( ( b < 0 ) && ( b < ipINT32_MIN_VALUE / a ) )
1755+
else if( ( b < 0 ) && ( b < ( ipINT32_MIN_VALUE / a ) ) )
17561756
{
17571757
ret = ipINT32_MIN_VALUE; /* Negative underflow */
17581758
}
@@ -1763,11 +1763,11 @@ int32_t FreeRTOS_multiply_int32( int32_t a,
17631763
}
17641764
else
17651765
{
1766-
if( ( b > 0 ) && ( a < ipINT32_MIN_VALUE / b ) )
1766+
if( ( b > 0 ) && ( a < ( ipINT32_MIN_VALUE / b ) ) )
17671767
{
17681768
ret = ipINT32_MIN_VALUE; /* Negative underflow */
17691769
}
1770-
else if( ( b < 0 ) && ( a < ipINT32_MAX_VALUE / b ) )
1770+
else if( ( b < 0 ) && ( a < ( ipINT32_MAX_VALUE / b ) ) )
17711771
{
17721772
ret = ipINT32_MAX_VALUE; /* Positive overflow */
17731773
}

source/FreeRTOS_ND.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@
9999

100100
/** @brief The time at which the last unsolicited ND was sent. Unsolicited NDs are used
101101
* to ensure ND tables are up to date and to detect IP address conflicts. */
102+
/* MISRA Ref 8.9.1 [File scoped variables] */
103+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-89 */
104+
/* coverity[misra_c_2012_rule_8_9_violation] */
102105
static TickType_t xLastUnsolicitedNDTime = 0U;
103106

104107
/*-----------------------------------------------------------*/

source/FreeRTOS_TCP_WIN.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,7 @@
19051905
int32_t lWeight = 0;
19061906
int32_t lDivisor = 0;
19071907

1908-
mS = mS < 0 ? ipINT32_MAX_VALUE : mS;
1908+
mS = ( mS < 0 ) ? ipINT32_MAX_VALUE : mS;
19091909

19101910
if( pxWindow->lSRTT >= mS )
19111911
{

source/include/FreeRTOS_IP.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@
6161
#define ipSIZE_OF_TCP_HEADER 20U
6262

6363
/* The maximum of int32 value. */
64-
#define ipINT32_MAX_VALUE ( ( int32_t ) 0x7FFFFFFF )
64+
#define ipINT32_MAX_VALUE ( ( int32_t ) 0x7FFFFFFFU )
6565

6666
/* The minimum of int32 value. */
67-
#define ipINT32_MIN_VALUE ( ( int32_t ) 0x80000000 )
67+
#define ipINT32_MIN_VALUE ( ( int32_t ) 0x80000000U )
6868

6969
/*
7070
* Generate a randomized TCP Initial Sequence Number per RFC.

0 commit comments

Comments
 (0)