Address various MISRA warnings v2 (#238)

* Address some MISRA warnings

* Change the return type

* Update FreeRTOS_Sockets.c
This commit is contained in:
Aniruddha Kanhere 2020-09-02 15:37:44 -07:00 committed by GitHub
parent 0341050048
commit cacf4ad7f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 14 deletions

View file

@ -1252,10 +1252,16 @@ BaseType_t xReturn = pdTRUE;
const uint16_t usCount = ( uint16_t ) ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY; const uint16_t usCount = ( uint16_t ) ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY;
uint16_t usNumARecordsStored = 0; uint16_t usNumARecordsStored = 0;
for( x = 0U; ( x < pxDNSMessageHeader->usAnswers ) && ( usNumARecordsStored < usCount ); x++ ) for( x = 0U; x < pxDNSMessageHeader->usAnswers; x++ )
{ {
BaseType_t xDoAccept; BaseType_t xDoAccept;
if( usNumARecordsStored >= usCount )
{
/* Only count ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY number of records. */
break;
}
uxResult = prvSkipNameField( pucByte, uxResult = prvSkipNameField( pucByte,
uxSourceBytesRemaining ); uxSourceBytesRemaining );

View file

@ -1883,7 +1883,7 @@ const socklen_t uxSize = 16;
{ {
uint8_t pucDigits[ sockDIGIT_COUNT ]; uint8_t pucDigits[ sockDIGIT_COUNT ];
uint8_t ucValue = pucAddress[ uxNibble ]; uint8_t ucValue = pucAddress[ uxNibble ];
socklen_t uxSource = sockDIGIT_COUNT - 1U; socklen_t uxSource = ( socklen_t ) sockDIGIT_COUNT - ( socklen_t ) 1U;
socklen_t uxNeeded; socklen_t uxNeeded;
for( ;; ) for( ;; )
@ -1899,7 +1899,7 @@ const socklen_t uxSize = 16;
pucDigits[ 0 ] = ucValue; pucDigits[ 0 ] = ucValue;
/* Skip leading zeros. */ /* Skip leading zeros. */
for( uxSource = 0; uxSource < ( socklen_t ) ( sockDIGIT_COUNT - 1U ); uxSource++ ) for( uxSource = 0; uxSource < ( ( socklen_t ) sockDIGIT_COUNT - ( socklen_t ) 1U ); uxSource++ )
{ {
if( pucDigits[ uxSource ] != 0U ) if( pucDigits[ uxSource ] != 0U )
{ {

View file

@ -313,11 +313,16 @@ BaseType_t FreeRTOS_IsNetworkUp( void );
* Socket has had activity, reset the timer so it will not be closed * Socket has had activity, reset the timer so it will not be closed
* because of inactivity * because of inactivity
*/ */
const char *FreeRTOS_GetTCPStateName( UBaseType_t ulState); #if( ( ipconfigHAS_DEBUG_PRINTF != 0 ) || ( ipconfigHAS_PRINTF != 0 ) )
const char *FreeRTOS_GetTCPStateName( UBaseType_t ulState);
#endif
/* _HT_ Temporary: show all valid ARP entries /* _HT_ Temporary: show all valid ARP entries
*/ */
void FreeRTOS_PrintARPCache( void ); #if( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 )
void FreeRTOS_PrintARPCache( void );
#endif
void FreeRTOS_ClearARP( void ); void FreeRTOS_ClearARP( void );
/* Return pdTRUE if the IPv4 address is a multicast address. */ /* Return pdTRUE if the IPv4 address is a multicast address. */

View file

@ -515,13 +515,6 @@ socket events. */
#define ARRAY_SIZE(x) ( ( BaseType_t ) ( sizeof( x ) / sizeof( ( x )[ 0 ] ) ) ) #define ARRAY_SIZE(x) ( ( BaseType_t ) ( sizeof( x ) / sizeof( ( x )[ 0 ] ) ) )
#endif #endif
/*
* A version of FreeRTOS_GetReleaseNetworkBuffer() that can be called from an
* interrupt. If a non zero value is returned, then the calling ISR should
* perform a context switch before exiting the ISR.
*/
BaseType_t FreeRTOS_ReleaseFreeNetworkBufferFromISR( void );
/* /*
* Create a message that contains a command to initialise the network interface. * Create a message that contains a command to initialise the network interface.
* This is used during initialisation, and at any time the network interface * This is used during initialisation, and at any time the network interface
@ -585,7 +578,9 @@ BaseType_t xIPIsNetworkTaskReady( void );
* Actually a user thing, but because xBoundTCPSocketsList, let it do by the * Actually a user thing, but because xBoundTCPSocketsList, let it do by the
* IP-task * IP-task
*/ */
void vTCPNetStat( void ); #if( ipconfigHAS_PRINTF != 0 )
void vTCPNetStat( void );
#endif
/* /*
* At least one socket needs to check for timeouts * At least one socket needs to check for timeouts

View file

@ -205,7 +205,7 @@ struct xSOCKET;
typedef struct xSOCKET *Socket_t; typedef struct xSOCKET *Socket_t;
typedef struct xSOCKET const * ConstSocket_t; typedef struct xSOCKET const * ConstSocket_t;
static portINLINE int prvSocketValid( Socket_t xSocket ) static portINLINE unsigned int prvSocketValid( Socket_t xSocket )
{ {
/* coverity[misra_c_2012_rule_11_4_violation] */ /* coverity[misra_c_2012_rule_11_4_violation] */
return ( ( xSocket != FREERTOS_INVALID_SOCKET ) && ( xSocket != NULL ) ); return ( ( xSocket != FREERTOS_INVALID_SOCKET ) && ( xSocket != NULL ) );