Skip to content

Commit cad1f75

Browse files
Fix MISRA2012 issues with Coverity version 2024.06 (#1196)
* 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
1 parent d89a9fa commit cad1f75

File tree

5 files changed

+43
-31
lines changed

5 files changed

+43
-31
lines changed

source/FreeRTOS_ARP.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress,
979979
if( pxEndPoint != NULL )
980980
{
981981
/* For multi-cast, use the first IPv4 end-point. */
982-
memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
982+
( void ) memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
983983
*( ppxEndPoint ) = pxEndPoint;
984984
eReturn = eARPCacheHit;
985985
}

source/FreeRTOS_DNS.c

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,41 +63,45 @@ const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc }
6363
/** @brief The IPv6 link-scope multicast MAC address */
6464
const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } };
6565

66+
#if ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
6667
/** @brief The IPv6 link-scope multicast address */
67-
const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6 =
68-
{
69-
{ /* ff02::1:3 */
70-
0xff, 0x02,
71-
0x00, 0x00,
72-
0x00, 0x00,
73-
0x00, 0x00,
74-
0x00, 0x00,
75-
0x00, 0x00,
76-
0x00, 0x01,
77-
0x00, 0x03,
78-
}
79-
};
68+
const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6 =
69+
{
70+
{ /* ff02::1:3 */
71+
0xff, 0x02,
72+
0x00, 0x00,
73+
0x00, 0x00,
74+
0x00, 0x00,
75+
0x00, 0x00,
76+
0x00, 0x00,
77+
0x00, 0x01,
78+
0x00, 0x03,
79+
}
80+
};
81+
#endif /* ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */
8082

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

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

89+
#if ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
8790
/** @brief multicast DNS IPv6 address */
88-
const IPv6_Address_t ipMDNS_IP_ADDR_IPv6 =
89-
{
90-
{ /* ff02::fb */
91-
0xff, 0x02,
92-
0x00, 0x00,
93-
0x00, 0x00,
94-
0x00, 0x00,
95-
0x00, 0x00,
96-
0x00, 0x00,
97-
0x00, 0x00,
98-
0x00, 0xfb,
99-
}
100-
};
91+
const IPv6_Address_t ipMDNS_IP_ADDR_IPv6 =
92+
{
93+
{ /* ff02::fb */
94+
0xff, 0x02,
95+
0x00, 0x00,
96+
0x00, 0x00,
97+
0x00, 0x00,
98+
0x00, 0x00,
99+
0x00, 0x00,
100+
0x00, 0x00,
101+
0x00, 0xfb,
102+
}
103+
};
104+
#endif /* ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */
101105

102106
/* Exclude the entire file if DNS is not enabled. */
103107
#if ( ipconfigUSE_DNS != 0 )

source/FreeRTOS_IP.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
982982
{
983983
static StaticTask_t xIPTaskBuffer;
984984
static StackType_t xIPTaskStack[ ipconfigIP_TASK_STACK_SIZE_WORDS ];
985-
xIPTaskHandle = xTaskCreateStatic( prvIPTask,
985+
xIPTaskHandle = xTaskCreateStatic( &prvIPTask,
986986
"IP-Task",
987987
ipconfigIP_TASK_STACK_SIZE_WORDS,
988988
NULL,
@@ -997,7 +997,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
997997
}
998998
#else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
999999
{
1000-
xReturn = xTaskCreate( prvIPTask,
1000+
xReturn = xTaskCreate( &prvIPTask,
10011001
"IP-task",
10021002
ipconfigIP_TASK_STACK_SIZE_WORDS,
10031003
NULL,

source/include/FreeRTOS_DNS.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ extern const MACAddress_t xLLMNR_MacAddress;
4747
/* The LLMNR IPv6 MAC address is 33:33:00:01:00:03 */
4848
extern const MACAddress_t xLLMNR_MacAddressIPv6;
4949

50+
#if ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
5051
/* The LLMNR IPv6 address is ff02::1:3 */
51-
extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6;
52+
extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6;
53+
#endif /* ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */
5254

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

66+
#if ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
6467
/* The MDNS IPv6 address is ff02::1:3 */
65-
extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6;
68+
extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6;
69+
#endif /* ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */
6670

6771
/** @brief While doing integration tests, it is necessary to influence the choice
6872
* between DNS/IPv4 and DNS/IPv4. Depending on this, a DNS server will be

test/Coverity/coverity_misra.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
deviation: "Rule 2.4",
4343
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."
4444
},
45+
{
46+
deviation: "Rule 17.11",
47+
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. "
48+
},
4549
{
4650
deviation: "Directive 4.8",
4751
reason: "We include lots of header files from other sources such as the kernel which defines structures that violate that Dir"

0 commit comments

Comments
 (0)