Skip to content

Commit

Permalink
Fix MISRA2012 issues with Coverity version 2024.06 (FreeRTOS#1196)
Browse files Browse the repository at this point in the history
* MISRA fix

* More MISRA fixes

* Add exception for Rule 17.11

* Fix comments

* Include externs inside preprocessor macros

* Taking global exception for Rule 17.11

* Fix formatting
  • Loading branch information
tony-josi-aws authored Oct 10, 2024
1 parent d89a9fa commit cad1f75
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 31 deletions.
2 changes: 1 addition & 1 deletion source/FreeRTOS_ARP.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress,
if( pxEndPoint != NULL )
{
/* For multi-cast, use the first IPv4 end-point. */
memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
( void ) memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
*( ppxEndPoint ) = pxEndPoint;
eReturn = eARPCacheHit;
}
Expand Down
56 changes: 30 additions & 26 deletions source/FreeRTOS_DNS.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,45 @@ const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc }
/** @brief The IPv6 link-scope multicast MAC address */
const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } };

#if ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
/** @brief The IPv6 link-scope multicast address */
const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6 =
{
{ /* ff02::1:3 */
0xff, 0x02,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x01,
0x00, 0x03,
}
};
const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6 =
{
{ /* ff02::1:3 */
0xff, 0x02,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x01,
0x00, 0x03,
}
};
#endif /* ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */

/** @brief The MAC address used for MDNS. */
const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } };

/** @brief The IPv6 multicast DNS MAC address. */
const MACAddress_t xMDNS_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } };

#if ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
/** @brief multicast DNS IPv6 address */
const IPv6_Address_t ipMDNS_IP_ADDR_IPv6 =
{
{ /* ff02::fb */
0xff, 0x02,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0xfb,
}
};
const IPv6_Address_t ipMDNS_IP_ADDR_IPv6 =
{
{ /* ff02::fb */
0xff, 0x02,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0xfb,
}
};
#endif /* ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */

/* Exclude the entire file if DNS is not enabled. */
#if ( ipconfigUSE_DNS != 0 )
Expand Down
4 changes: 2 additions & 2 deletions source/FreeRTOS_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
{
static StaticTask_t xIPTaskBuffer;
static StackType_t xIPTaskStack[ ipconfigIP_TASK_STACK_SIZE_WORDS ];
xIPTaskHandle = xTaskCreateStatic( prvIPTask,
xIPTaskHandle = xTaskCreateStatic( &prvIPTask,
"IP-Task",
ipconfigIP_TASK_STACK_SIZE_WORDS,
NULL,
Expand All @@ -997,7 +997,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
}
#else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
{
xReturn = xTaskCreate( prvIPTask,
xReturn = xTaskCreate( &prvIPTask,
"IP-task",
ipconfigIP_TASK_STACK_SIZE_WORDS,
NULL,
Expand Down
8 changes: 6 additions & 2 deletions source/include/FreeRTOS_DNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ extern const MACAddress_t xLLMNR_MacAddress;
/* The LLMNR IPv6 MAC address is 33:33:00:01:00:03 */
extern const MACAddress_t xLLMNR_MacAddressIPv6;

#if ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
/* The LLMNR IPv6 address is ff02::1:3 */
extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6;
extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6;
#endif /* ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */

/* The MDNS MAC address is 01:00:5e:00:00:fc */
extern const MACAddress_t xMDNS_MacAddress;
Expand All @@ -61,8 +63,10 @@ extern const MACAddress_t xMDNS_MacAddressIPv6;
/* Guarantee backward compatibility. */
#define xMDNS_MACAddressIPv6 xMDNS_MacAddressIPv6

#if ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
/* The MDNS IPv6 address is ff02::1:3 */
extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6;
extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6;
#endif /* ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */

/** @brief While doing integration tests, it is necessary to influence the choice
* between DNS/IPv4 and DNS/IPv4. Depending on this, a DNS server will be
Expand Down
4 changes: 4 additions & 0 deletions test/Coverity/coverity_misra.config
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
deviation: "Rule 2.4",
reason: "Similar to the FreeRTOS Kernel, structures are always declared with both a struct tag and typedef alias. Some of these structs are always referred to by their typedef alias and thus the corresponding tags are unused."
},
{
deviation: "Rule 17.11",
reason: "_Noreturn is added by C standard as part of C11 and the FreeRTOS+TCP codebase is compatible with C90. This is a false positive as the Coverity is also run with C90 as the standard. "
},
{
deviation: "Directive 4.8",
reason: "We include lots of header files from other sources such as the kernel which defines structures that violate that Dir"
Expand Down

0 comments on commit cad1f75

Please sign in to comment.