Skip to content

Commit f8c7271

Browse files
xuelixgitwallit
andauthored
MISRA violation fix 17.7, 1.2, 8.9 (#530)
* MISRA violation fix 17.7, 1.2, 8.9 * Fixing spell check error * Added comment for PR review Co-authored-by: gitwallit <[email protected]>
1 parent 11f2272 commit f8c7271

File tree

5 files changed

+30
-18
lines changed

5 files changed

+30
-18
lines changed

.github/lexicon.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ callbacklist
9393
calloc
9494
cambridge
9595
camen
96+
caretline
9697
carriersense
9798
castingmacrofunctions
9899
cbmc

source/FreeRTOS_DNS_Cache.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,13 @@
173173
{ /* Element found */
174174
if( xLookUp == pdTRUE )
175175
{
176-
prvGetCacheIPEntry( uxIndex,
177-
pulIP,
178-
ulCurrentTimeSeconds );
176+
/* This statement can only be reached when xResult is true; which
177+
* implies that the entry is present and a 'get' operation will result
178+
* in success. Therefore, it is safe to ignore the return value of the
179+
* below function. */
180+
( void ) prvGetCacheIPEntry( uxIndex,
181+
pulIP,
182+
ulCurrentTimeSeconds );
179183
}
180184
else
181185
{

source/FreeRTOS_IP_Utils.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static NetworkBufferDescriptor_t * prvPacketBuffer_to_NetworkBuffer( const void
136136
xEventMessage.eEventType = eDHCPEvent;
137137

138138
/* MISRA Ref 11.6.1 [DHCP events and conversion to void] */
139-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-116 */
139+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-116 */
140140
/* coverity[misra_c_2012_rule_11_6_violation] */
141141
xEventMessage.pvData = ( void * ) uxOption;
142142

@@ -231,7 +231,7 @@ static NetworkBufferDescriptor_t * prvPacketBuffer_to_NetworkBuffer( const void
231231
/* Obtain the network buffer from the zero copy pointer. */
232232

233233
/* MISRA Ref 11.6.2 [Pointer arithmetic and hidden pointer] */
234-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-116 */
234+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-116 */
235235
/* coverity[misra_c_2012_rule_11_6_violation] */
236236
uxBuffer = ( uintptr_t ) pvBuffer;
237237

@@ -245,7 +245,7 @@ static NetworkBufferDescriptor_t * prvPacketBuffer_to_NetworkBuffer( const void
245245
if( ( uxBuffer & ( ( ( uintptr_t ) sizeof( uxBuffer ) ) - 1U ) ) == ( uintptr_t ) 0U )
246246
{
247247
/* MISRA Ref 11.4.2 [Validation of pointer alignment] */
248-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
248+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
249249
/* coverity[misra_c_2012_rule_11_4_violation] */
250250
pxResult = *( ( NetworkBufferDescriptor_t ** ) uxBuffer );
251251
}
@@ -321,6 +321,10 @@ BaseType_t xIsCallingFromIPTask( void )
321321
/**
322322
* @brief Process a 'Network down' event and complete required processing.
323323
*/
324+
/* MISRA Ref 8.9.1 [File scoped variables] */
325+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-89 */
326+
/* coverity[misra_c_2012_rule_8_9_violation] */
327+
/* coverity[single_use] */
324328
void prvProcessNetworkDownEvent( void )
325329
{
326330
/* Stop the ARP timer while there is no network. */
@@ -473,7 +477,7 @@ uint16_t usGenerateProtocolChecksum( uint8_t * pucEthernetBuffer,
473477
/* Parse the packet length. */
474478

475479
/* MISRA Ref 11.3.1 [Misaligned access] */
476-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
480+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
477481
/* coverity[misra_c_2012_rule_11_3_violation] */
478482
pxIPPacket = ( ( const IPPacket_t * ) pucEthernetBuffer );
479483

@@ -518,7 +522,7 @@ uint16_t usGenerateProtocolChecksum( uint8_t * pucEthernetBuffer,
518522
* of this calculation. */
519523

520524
/* MISRA Ref 11.3.1 [Misaligned access] */
521-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
525+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
522526
/* coverity[misra_c_2012_rule_11_3_violation] */
523527
pxProtPack = ( ( ProtocolPacket_t * ) &( pucEthernetBuffer[ uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ] ) );
524528

@@ -848,7 +852,7 @@ uint16_t usGenerateChecksum( uint16_t usSum,
848852
xSource.u8ptr = pucNextData;
849853

850854
/* MISRA Ref 11.4.3 [Casting pointer to int for verification] */
851-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
855+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
852856
/* coverity[misra_c_2012_rule_11_4_violation] */
853857
uxAlignBits = ( ( ( uintptr_t ) pucNextData ) & 0x03U );
854858

@@ -956,21 +960,23 @@ uint16_t usGenerateChecksum( uint16_t usSum,
956960
}
957961

958962
/* MISRA Ref 2.2.1 [Unions and dead code] */
959-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-22 */
963+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-22 */
960964
/* coverity[misra_c_2012_rule_2_2_violation] */
965+
/* coverity[assigned_value] */
961966
xSum.u32 += xTerm.u32;
962967

963968
/* Now add all carries again. */
964969

965-
/* Assigning value from "xTerm.u32" to "xSum.u32" here, but that stored value is overwritten before it can be used.
966-
* /* MISRA Ref 2.2.1 [Unions and dead code] */
967-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-22 */
970+
/* Assigning value from "xTerm.u32" to "xSum.u32" here, but that stored value is overwritten before it can be used. */
971+
/* MISRA Ref 2.2.1 [Unions and dead code] */
972+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-22 */
968973
/* coverity[misra_c_2012_rule_2_2_violation] */
974+
/* coverity[value_overwrite] */
969975
xSum.u32 = ( uint32_t ) xSum.u16[ 0 ] + xSum.u16[ 1 ];
970976

971977
/* coverity[value_overwrite] */
972978
/* MISRA Ref 2.2.1 [Unions and dead code] */
973-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-22 */
979+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-22 */
974980
/* coverity[misra_c_2012_rule_2_2_violation] */
975981
xSum.u32 = ( uint32_t ) xSum.u16[ 0 ] + xSum.u16[ 1 ];
976982

@@ -1149,7 +1155,7 @@ const char * FreeRTOS_strerror_r( BaseType_t xErrnum,
11491155

11501156
default:
11511157
/* MISRA Ref 21.6.1 [snprintf and logging] */
1152-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-216 */
1158+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-216 */
11531159
/* coverity[misra_c_2012_rule_21_6_violation] */
11541160
( void ) snprintf( pcBuffer, uxLength, "Errno %d", xErrnum );
11551161
pcName = NULL;
@@ -1159,7 +1165,7 @@ const char * FreeRTOS_strerror_r( BaseType_t xErrnum,
11591165
if( pcName != NULL )
11601166
{
11611167
/* MISRA Ref 21.6.1 [snprintf and logging] */
1162-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-216 */
1168+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-216 */
11631169
/* coverity[misra_c_2012_rule_21_6_violation] */
11641170
( void ) snprintf( pcBuffer, uxLength, "%s", pcName );
11651171
}

source/FreeRTOS_Stream_Buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ size_t uxStreamBufferAdd( StreamBuffer_t * pxBuffer,
341341
pxBuffer->uxFront = uxNextHead;
342342
}
343343
}
344-
xTaskResumeAll();
344+
( void ) xTaskResumeAll();
345345
}
346346

347347
return uxCount;

test/Coverity/ConfigFiles/pack_struct_end.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@
3636
* placement in memory. */
3737

3838
/* The language extension is used in a portable manner for each specific compiler */
39-
/* coverity[misra_c_2012_rule_1_2_violation]*/
39+
/* coverity[misra_c_2012_rule_1_2_violation] */
40+
/* coverity[caretline] */
4041
__attribute__( ( packed ) );

0 commit comments

Comments
 (0)