Address MISRA Rule violations (#274)

* Use unsigned types/constants where needed.

* Address MISRA 21.15 violations in FreeRTOS_Sockets.c

* Address MISRA rule violations in code (primarily Rule 2.2)

* Inline had been disabled for Coverity builds, preventing
Coverity from correctly identifying dead code; this change
removes the disabling of inline during Coverity builds.
* Added an explanation for the inline suppression of Rule
11.4 in prvSocketValid().

Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>
This commit is contained in:
Gary Wicker 2020-09-16 14:53:57 -07:00 committed by GitHub
parent 50dc98a5a6
commit c997d887e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 50 deletions

View file

@ -207,8 +207,19 @@ typedef struct xSOCKET const * ConstSocket_t;
static portINLINE unsigned int prvSocketValid( Socket_t xSocket )
{
unsigned int lReturnValue = pdFALSE;
/*
* There are two values which can indicate an invalid socket:
* FREERTOS_INVALID_SOCKET and NULL. In order to compare against
* both values, the code cannot be compliant with rule 11.4,
* hence the Coverity suppression statement below.
*/
/* coverity[misra_c_2012_rule_11_4_violation] */
return ( ( xSocket != FREERTOS_INVALID_SOCKET ) && ( xSocket != NULL ) );
if( ( xSocket != FREERTOS_INVALID_SOCKET ) && ( xSocket != NULL ) )
{
lReturnValue = pdTRUE;
}
return lReturnValue;
}
#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 )