Skip to content

Commit

Permalink
Fix Clang warnings (#984)
Browse files Browse the repository at this point in the history
* CMAKe update

* Fix Wdocumentation errors

* Fix Wconditional-uninitialized

* Fix [-Wformat-pedantic

* Fix Wcompound-token-split-by-space and Wgnu-statement-expression

* Add suppression

* Uncrustify: triggered by comment.

* Fix coverity

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
moninom1 and actions-user authored Jul 28, 2023
1 parent b23fa86 commit 574b646
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 67 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,21 @@ add_compile_options(
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wall>
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wextra>
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Werror>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wpedantic>
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wconversion>
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wunused-variable>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Weverything>

# Suppressions required to build clean with clang.
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-unused-macros>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-qual>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-switch-enum>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-declaration-after-statement>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-padded>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-variable-declarations>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-covered-switch-default>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-extra-semi-stmt>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-noreturn>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-align>
)

Expand Down
6 changes: 3 additions & 3 deletions source/FreeRTOS_ARP.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw
( ucNextHeader == ipPROTOCOL_UDP ) )
{
IPv6_Type_t eType = xIPv6_GetIPType( ( const IPv6_Address_t * ) pxIPAddress );
FreeRTOS_printf( ( "xCheckRequiresARPResolution: %pip type %s\n", pxIPAddress->ucBytes, ( eType == eIPv6_Global ) ? "Global" : ( eType == eIPv6_LinkLocal ) ? "LinkLocal" : "other" ) );
FreeRTOS_printf( ( "xCheckRequiresARPResolution: %pip type %s\n", ( void * ) pxIPAddress->ucBytes, ( eType == eIPv6_Global ) ? "Global" : ( eType == eIPv6_LinkLocal ) ? "LinkLocal" : "other" ) );

if( eType == eIPv6_LinkLocal )
{
Expand Down Expand Up @@ -637,8 +637,8 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw
* @brief Look for an IP-MAC couple in ARP cache and reset the 'age' field. If no match
* is found then no action will be taken.
*
* @param[in] pxMACAddress: Pointer to the MAC address whose entry needs to be updated.
* @param[in] ulIPAddress: the IP address whose corresponding entry needs to be updated.
* @param[in] pxMACAddress Pointer to the MAC address whose entry needs to be updated.
* @param[in] ulIPAddress the IP address whose corresponding entry needs to be updated.
*/
void vARPRefreshCacheEntryAge( const MACAddress_t * pxMACAddress,
const uint32_t ulIPAddress )
Expand Down
6 changes: 3 additions & 3 deletions source/FreeRTOS_BitConfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ BaseType_t xBitConfig_read_uc( BitConfig_t * pxConfig,
/**
* @brief Peek the last byte from a bit-config struct.
*
* @param[in] pxConfig: The structure containing a copy of the bits.
* @param[in] pucData: The buffer to stored peeked data.
* @param[in] uxSize: The length of the binary data stream.
* @param[in] pxConfig The structure containing a copy of the bits.
* @param[in] pucData The buffer to stored peeked data.
* @param[in] uxSize The length of the binary data stream.
*
* @return pdTRUE if the malloc was OK, otherwise pdFALSE.
*/
Expand Down
14 changes: 7 additions & 7 deletions source/FreeRTOS_DHCPv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ eDHCPState_t eGetDHCPv6State( struct xNetworkEndPoint * pxEndPoint )
/**
* @brief Check if option length is less than buffer size and larger than minimum requirement.
*
* @param[in] usOption: The option code.
* @param[in] uxOptionLength: The option length to check.
* @param[in] uxRemainingSize: Remaining size in the buffer.
* @param[in] usOption The option code.
* @param[in] uxOptionLength The option length to check.
* @param[in] uxRemainingSize Remaining size in the buffer.
*
* @return pdTRUE if the length is valid, otherwise pdFALSE.
*/
Expand Down Expand Up @@ -254,8 +254,8 @@ static BaseType_t prvIsOptionLengthValid( uint16_t usOption,

/**
* @brief A DHCP packet has a list of options, one of them is Status Code. This function is used to parse it.
* @param[in] uxLength: Total length for status code.
* @param[in] pxMessage: The raw packet as it was received.
* @param[in] uxLength Total length for status code.
* @param[in] pxMessage The raw packet as it was received.
*
* @return pdTRUE if status is success, otherwise pdFALSE.
*/
Expand Down Expand Up @@ -1159,15 +1159,15 @@ static BaseType_t prvDHCPv6_subOption( uint16_t usOption,
( void ) xBitConfig_read_uc( pxMessage, pxDHCPMessage->xIPAddress.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
pxDHCPMessage->ulPreferredLifeTime = ulBitConfig_read_32( pxMessage );
pxDHCPMessage->ulValidLifeTime = ulBitConfig_read_32( pxMessage );
FreeRTOS_printf( ( "IP Address %pip\n", pxDHCPMessage->xIPAddress.xIP_IPv6.ucBytes ) );
FreeRTOS_printf( ( "IP Address %pip\n", ( void * ) pxDHCPMessage->xIPAddress.xIP_IPv6.ucBytes ) );
break;

case DHCPv6_Option_IA_Prefix:
pxDHCPMessage->ulPreferredLifeTime = ulBitConfig_read_32( pxMessage );
pxDHCPMessage->ulValidLifeTime = ulBitConfig_read_32( pxMessage );
pxDHCPMessage->ucprefixLength = ucBitConfig_read_8( pxMessage );
( void ) xBitConfig_read_uc( pxMessage, pxDHCPMessage->xPrefixAddress.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
FreeRTOS_printf( ( "Address prefix: %pip length %d\n", pxDHCPMessage->xPrefixAddress.xIP_IPv6.ucBytes, pxDHCPMessage->ucprefixLength ) );
FreeRTOS_printf( ( "Address prefix: %pip length %d\n", ( void * ) pxDHCPMessage->xPrefixAddress.xIP_IPv6.ucBytes, pxDHCPMessage->ucprefixLength ) );
break;

case DHCPv6_Option_Status_Code:
Expand Down
2 changes: 1 addition & 1 deletion source/FreeRTOS_DNS.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@
if( ( ppxAddressInfo != NULL ) && ( ( *ppxAddressInfo )->ai_family == FREERTOS_AF_INET6 ) )
{
FreeRTOS_printf( ( "prvPrepareLookup: found '%s' in cache: %pip\n",
pcHostName, ( *ppxAddressInfo )->xPrivateStorage.sockaddr.sin_address.xIP_IPv6.ucBytes ) );
pcHostName, ( void * ) ( *ppxAddressInfo )->xPrivateStorage.sockaddr.sin_address.xIP_IPv6.ucBytes ) );
}
else
#endif
Expand Down
2 changes: 1 addition & 1 deletion source/FreeRTOS_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke
NetworkBufferDescriptor_t * const pxNetworkBuffer )
{
eFrameProcessingResult_t eReturn;
UBaseType_t uxHeaderLength;
UBaseType_t uxHeaderLength = ipSIZE_OF_IPv4_HEADER;
uint8_t ucProtocol = 0U;

#if ( ipconfigUSE_IPv6 != 0 )
Expand Down
38 changes: 19 additions & 19 deletions source/FreeRTOS_ND.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@

if( eReturn == eARPCacheMiss )
{
FreeRTOS_printf( ( "eNDGetCacheEntry: lookup %pip miss\n", pxIPAddress->ucBytes ) );
FreeRTOS_printf( ( "eNDGetCacheEntry: lookup %pip miss\n", ( void * ) pxIPAddress->ucBytes ) );
}

if( eReturn == eARPCacheMiss )
Expand All @@ -219,8 +219,8 @@
}

FreeRTOS_printf( ( "eNDGetCacheEntry: FindEndPointOnIP failed for %pip (endpoint %pip)\n",
pxIPAddress->ucBytes,
pxEndPoint->ipv6_settings.xIPAddress.ucBytes ) );
( void * ) pxIPAddress->ucBytes,
( void * ) pxEndPoint->ipv6_settings.xIPAddress.ucBytes ) );
}
else
{
Expand All @@ -239,7 +239,7 @@
}
}

FreeRTOS_printf( ( "eNDGetCacheEntry: LinkLocal %pip \"%s\"\n", pxIPAddress->ucBytes,
FreeRTOS_printf( ( "eNDGetCacheEntry: LinkLocal %pip \"%s\"\n", ( void * ) pxIPAddress->ucBytes,
( eReturn == eARPCacheHit ) ? "hit" : "miss" ) );
}
else
Expand All @@ -249,15 +249,15 @@
if( pxEndPoint != NULL )
{
( void ) memcpy( pxIPAddress->ucBytes, pxEndPoint->ipv6_settings.xGatewayAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
FreeRTOS_printf( ( "eNDGetCacheEntry: Using gw %pip\n", pxIPAddress->ucBytes ) );
FreeRTOS_printf( ( "eNDGetCacheEntry: From addr %pip\n", pxEndPoint->ipv6_settings.xIPAddress.ucBytes ) );
FreeRTOS_printf( ( "eNDGetCacheEntry: Using gw %pip\n", ( void * ) pxIPAddress->ucBytes ) );
FreeRTOS_printf( ( "eNDGetCacheEntry: From addr %pip\n", ( void * ) pxEndPoint->ipv6_settings.xIPAddress.ucBytes ) );

/* See if the gateway has an entry in the cache. */
eReturn = prvNDCacheLookup( pxIPAddress, pxMACAddress, ppxEndPoint );

if( *ppxEndPoint != NULL )
{
FreeRTOS_printf( ( "eNDGetCacheEntry: found end-point %pip\n", ( *ppxEndPoint )->ipv6_settings.xIPAddress.ucBytes ) );
FreeRTOS_printf( ( "eNDGetCacheEntry: found end-point %pip\n", ( void * ) ( *ppxEndPoint )->ipv6_settings.xIPAddress.ucBytes ) );
}

*( ppxEndPoint ) = pxEndPoint;
Expand Down Expand Up @@ -325,7 +325,7 @@
}
else
{
FreeRTOS_printf( ( "vNDRefreshCacheEntry: %pip not found\n", pxIPAddress->ucBytes ) );
FreeRTOS_printf( ( "vNDRefreshCacheEntry: %pip not found\n", ( void * ) pxIPAddress->ucBytes ) );
}
}
/*-----------------------------------------------------------*/
Expand Down Expand Up @@ -442,7 +442,7 @@

FreeRTOS_debug_printf( ( "prvCacheLookup6[ %d ] %pip with %02x:%02x:%02x:%02x:%02x:%02x\n",
( int ) x,
pxAddressToLookup->ucBytes,
( void * ) pxAddressToLookup->ucBytes,
pxMACAddress->ucBytes[ 0 ],
pxMACAddress->ucBytes[ 1 ],
pxMACAddress->ucBytes[ 2 ],
Expand All @@ -459,7 +459,7 @@

if( eReturn == eARPCacheMiss )
{
FreeRTOS_printf( ( "prvNDCacheLookup %pip Miss\n", pxAddressToLookup->ucBytes ) );
FreeRTOS_printf( ( "prvNDCacheLookup %pip Miss\n", ( void * ) pxAddressToLookup->ucBytes ) );

if( ppxEndPoint != NULL )
{
Expand Down Expand Up @@ -491,7 +491,7 @@
FreeRTOS_printf( ( "ND %2d: age %3u - %pip MAC %02x-%02x-%02x-%02x-%02x-%02x endPoint %s\n",
( int ) x,
xNDCache[ x ].ucAge,
xNDCache[ x ].xIPAddress.ucBytes,
( void * ) xNDCache[ x ].xIPAddress.ucBytes,
xNDCache[ x ].xMACAddress.ucBytes[ 0 ],
xNDCache[ x ].xMACAddress.ucBytes[ 1 ],
xNDCache[ x ].xMACAddress.ucBytes[ 2 ],
Expand Down Expand Up @@ -729,7 +729,7 @@
{
/* No endpoint found for the target IP-address. */
FreeRTOS_printf( ( "SendPingRequestIPv6: no end-point found for %pip\n",
pxIPAddress->ucBytes ) );
( void * ) pxIPAddress->ucBytes ) );
}
else if( ( uxGetNumberOfFreeNetworkBuffers() >= 3U ) && ( uxNumberOfBytesToSend >= 1U ) && ( xEnoughSpace != pdFALSE ) )
{
Expand Down Expand Up @@ -761,7 +761,7 @@
pxICMPPacket->xIPHeader.usPayloadLength = FreeRTOS_htons( sizeof( ICMPEcho_IPv6_t ) + uxNumberOfBytesToSend );
( void ) memcpy( pxICMPPacket->xIPHeader.xDestinationAddress.ucBytes, pxIPAddress->ucBytes, ipSIZE_OF_IPv6_ADDRESS );
( void ) memcpy( pxICMPPacket->xIPHeader.xSourceAddress.ucBytes, pxEndPoint->ipv6_settings.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
FreeRTOS_printf( ( "ICMP send from %pip\n", pxICMPPacket->xIPHeader.xSourceAddress.ucBytes ) );
FreeRTOS_printf( ( "ICMP send from %pip\n", ( void * ) pxICMPPacket->xIPHeader.xSourceAddress.ucBytes ) );

/* Fill in the basic header information. */
pxICMPHeader->ucTypeOfMessage = ipICMP_PING_REQUEST_IPv6;
Expand Down Expand Up @@ -949,8 +949,8 @@
FreeRTOS_printf( ( "ICMPv6_recv %d (%s) from %pip to %pip end-point = %s\n",
pxICMPHeader_IPv6->ucTypeOfMessage,
pcMessageType( ( BaseType_t ) pxICMPHeader_IPv6->ucTypeOfMessage ),
pxICMPPacket->xIPHeader.xSourceAddress.ucBytes,
pxICMPPacket->xIPHeader.xDestinationAddress.ucBytes,
( void * ) pxICMPPacket->xIPHeader.xSourceAddress.ucBytes,
( void * ) pxICMPPacket->xIPHeader.xDestinationAddress.ucBytes,
pcEndpointName( pxEndPoint, pcAddress, sizeof( pcAddress ) ) ) );
}
}
Expand Down Expand Up @@ -1032,7 +1032,7 @@
char pcName[ 40 ];
( void ) memset( &( pcName ), 0, sizeof( pcName ) );
FreeRTOS_printf( ( "Lookup %pip : endpoint %s\n",
pxICMPHeader_IPv6->xIPv6Address.ucBytes,
( void * ) pxICMPHeader_IPv6->xIPv6Address.ucBytes,
pcEndpointName( pxEndPointFound, pcName, sizeof( pcName ) ) ) );

if( pxEndPointFound != NULL )
Expand All @@ -1055,8 +1055,8 @@
xCompare = memcmp( pxICMPHeader_IPv6->xIPv6Address.ucBytes, pxEndPoint->ipv6_settings.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );

FreeRTOS_printf( ( "ND NS for %pip endpoint %pip %s\n",
pxICMPHeader_IPv6->xIPv6Address.ucBytes,
pxEndPoint->ipv6_settings.xIPAddress.ucBytes,
( void * ) pxICMPHeader_IPv6->xIPv6Address.ucBytes,
( void * ) pxEndPoint->ipv6_settings.xIPAddress.ucBytes,
( xCompare == 0 ) ? "Reply" : "Ignore" ) );

if( xCompare == 0 )
Expand Down Expand Up @@ -1086,7 +1086,7 @@
&( pxICMPHeader_IPv6->xIPv6Address ),
pxEndPoint );
FreeRTOS_printf( ( "NEIGHBOR_ADV from %pip\n",
pxICMPHeader_IPv6->xIPv6Address.ucBytes ) );
( void * ) pxICMPHeader_IPv6->xIPv6Address.ucBytes ) );

#if ( ipconfigUSE_RA != 0 )

Expand Down
12 changes: 6 additions & 6 deletions source/FreeRTOS_RA.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
}
else
{
FreeRTOS_printf( ( "RA: source %pip\n", xSourceAddress.ucBytes ) );
FreeRTOS_printf( ( "RA: source %pip\n", ( void * ) xSourceAddress.ucBytes ) );
}

if( pxDescriptor->xDataLength < uxNeededSize )
Expand Down Expand Up @@ -318,7 +318,7 @@
pxPrefixOption->ucPrefixLength,
FreeRTOS_ntohl( pxPrefixOption->ulValidLifeTime ),
FreeRTOS_ntohl( pxPrefixOption->ulPreferredLifeTime ),
pxPrefixOption->ucPrefix ) );
( void * ) pxPrefixOption->ucPrefix ) );
break;

case ndICMP_REDIRECTED_HEADER: /* 4 */
Expand Down Expand Up @@ -489,7 +489,7 @@
pxEndPoint->xRAData.eRAState = eRAStatePreLease;
iptraceRA_SUCCEDEED( &( pxEndPoint->ipv6_settings.xIPAddress ) );
FreeRTOS_printf( ( "RA: succeeded, using IP address %pip Reload after %u seconds\n",
pxEndPoint->ipv6_settings.xIPAddress.ucBytes,
( void * ) pxEndPoint->ipv6_settings.xIPAddress.ucBytes,
( unsigned ) pxEndPoint->xRAData.ulPreferredLifeTime ) );
}
else
Expand All @@ -499,7 +499,7 @@

iptraceRA_REQUESTS_FAILED_USING_DEFAULT_IP_ADDRESS( &( pxEndPoint->ipv6_settings.xIPAddress ) );

FreeRTOS_printf( ( "RA: failed, using default parameters and IP address %pip\n", pxEndPoint->ipv6_settings.xIPAddress.ucBytes ) );
FreeRTOS_printf( ( "RA: failed, using default parameters and IP address %pip\n", ( void * ) pxEndPoint->ipv6_settings.xIPAddress.ucBytes ) );
/* Disable the timer. */
uxNewReloadTime = 0U;
}
Expand Down Expand Up @@ -577,7 +577,7 @@
FreeRTOS_printf( ( "RA: Creating a random IP-address\n" ) );
}

FreeRTOS_printf( ( "RA: Neighbour solicitation for %pip\n", pxEndPoint->ipv6_settings.xIPAddress.ucBytes ) );
FreeRTOS_printf( ( "RA: Neighbour solicitation for %pip\n", ( void * ) pxEndPoint->ipv6_settings.xIPAddress.ucBytes ) );

uxNeededSize = ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + sizeof( ICMPHeader_IPv6_t );
pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( uxNeededSize, raDONT_BLOCK );
Expand Down Expand Up @@ -661,7 +661,7 @@
{
FreeRTOS_printf( ( "vRAProcess( %ld, %pip) bRouterReplied=%d bIPAddressInUse=%d state %d -> %d\n",
xDoReset,
pxEndPoint->ipv6_defaults.xIPAddress.ucBytes,
( void * ) pxEndPoint->ipv6_defaults.xIPAddress.ucBytes,
pxEndPoint->xRAData.bits.bRouterReplied,
pxEndPoint->xRAData.bits.bIPAddressInUse,
eRAState,
Expand Down
Loading

0 comments on commit 574b646

Please sign in to comment.