mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-17 18:27:47 -04:00
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:
parent
50dc98a5a6
commit
c997d887e0
3 changed files with 42 additions and 50 deletions
|
@ -38,20 +38,6 @@ extern "C" {
|
|||
#include "FreeRTOSIPConfigDefaults.h"
|
||||
#include "IPTraceMacroDefaults.h"
|
||||
|
||||
#ifdef __COVERITY__
|
||||
/* Coverity static checks don't like inlined functions.
|
||||
As it is up to the users to allow inlining, don't let
|
||||
let Coverity know about it. */
|
||||
|
||||
#ifdef portINLINE
|
||||
/* The usage of #undef violates the rule. */
|
||||
#undef portINLINE
|
||||
|
||||
#endif
|
||||
|
||||
#define portINLINE
|
||||
#endif
|
||||
|
||||
/* Some constants defining the sizes of several parts of a packet.
|
||||
These defines come before inlucding the configuration header files. */
|
||||
/* The size of the Ethernet header is 14, meaning that 802.1Q VLAN tags
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue