Skip to content

Commit

Permalink
Address various MISRA warnings v3 (#240)
Browse files Browse the repository at this point in the history
* Add a branch and make MISRA changes

* initialize the value

* Update after Gary's comments
  • Loading branch information
AniruddhaKanhere authored Sep 3, 2020
1 parent cacf4ad commit 05b4d4f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
10 changes: 6 additions & 4 deletions FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ FreeRTOS_Socket_t const *pxSocket = NULL;
Socket_t FreeRTOS_socket( BaseType_t xDomain, BaseType_t xType, BaseType_t xProtocol )
{
FreeRTOS_Socket_t *pxSocket;
size_t uxSocketSize;
size_t uxSocketSize = 0;
EventGroupHandle_t xEventGroup;
Socket_t xReturn;

Expand All @@ -311,8 +311,8 @@ Socket_t xReturn;
}
else
{
/* Allocate the structure that will hold the socket information. The
size depends on the type of socket: UDP sockets need less space. A
/* Allocate the structure that will hold the socket information. The
size depends on the type of socket: UDP sockets need less space. A
define 'pvPortMallocSocket' will used to allocate the necessary space.
By default it points to the FreeRTOS function 'pvPortMalloc()'. */
pxSocket = ipCAST_PTR_TO_TYPE_PTR( FreeRTOS_Socket_t, pvPortMallocSocket( uxSocketSize ) );
Expand Down Expand Up @@ -667,6 +667,7 @@ BaseType_t xTimed = pdFALSE;
TimeOut_t xTimeOut;
int32_t lReturn;
EventBits_t xEventBits = ( EventBits_t ) 0;
size_t uxPayloadLength;

if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_UDP, pdTRUE ) == pdFALSE )
{
Expand Down Expand Up @@ -770,7 +771,8 @@ EventBits_t xEventBits = ( EventBits_t ) 0;
calculated at the total packet size minus the headers.
The validity of `xDataLength` prvProcessIPPacket has been confirmed
in 'prvProcessIPPacket()'. */
lReturn = ( int32_t ) ( pxNetworkBuffer->xDataLength - sizeof( UDPPacket_t ) );
uxPayloadLength = pxNetworkBuffer->xDataLength - sizeof( UDPPacket_t );
lReturn = ( int32_t ) uxPayloadLength;

if( pxSourceAddress != NULL )
{
Expand Down
6 changes: 5 additions & 1 deletion FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -2678,6 +2678,8 @@ const TCPWindow_t *pxTCPWindow = &pxSocket->u.xTCP.xTCPWindow;
/* Find out what window size we may advertised. */
int32_t lRxSpace;
BaseType_t xSendLength = xByteCount;
uint32_t ulRxBufferSpace;

#if( ipconfigUSE_TCP_WIN == 1 )
#if( ipconfigTCP_ACK_EARLIER_PACKET == 0 )
const int32_t lMinLength = 0;
Expand All @@ -2688,7 +2690,9 @@ BaseType_t xSendLength = xByteCount;

/* Set the time-out field, so that we'll be called by the IP-task in case no
next message will be received. */
lRxSpace = ipNUMERIC_CAST( int32_t, pxSocket->u.xTCP.ulHighestRxAllowed - pxTCPWindow->rx.ulCurrentSequenceNumber );
ulRxBufferSpace = pxSocket->u.xTCP.ulHighestRxAllowed - pxTCPWindow->rx.ulCurrentSequenceNumber;
lRxSpace = ( int32_t ) ulRxBufferSpace;

#if ipconfigUSE_TCP_WIN == 1
{

Expand Down
9 changes: 5 additions & 4 deletions FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_WIN.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ const int32_t l500ms = 500;

int32_t lTCPWindowRxCheck( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber, uint32_t ulLength, uint32_t ulSpace )
{
uint32_t ulCurrentSequenceNumber, ulLast, ulSavedSequenceNumber;
uint32_t ulCurrentSequenceNumber, ulLast, ulSavedSequenceNumber, ulSequenceNumberDiff;
int32_t lReturn, lDistance;
TCPSegment_t *pxFound;

Expand Down Expand Up @@ -909,9 +909,10 @@ const int32_t l500ms = 500;
/* An "out-of-sequence" segment was received, must have missed one.
Prepare a SACK (Selective ACK). */
ulLast = ulSequenceNumber + ulLength;
/* The cast from unsigned long to signed long is on purpose.
The macro 'ipNUMERIC_CAST' will prevent PC-lint from complaining. */
lDistance = ipNUMERIC_CAST( int32_t, ulLast - ulCurrentSequenceNumber );

ulSequenceNumberDiff = ulLast - ulCurrentSequenceNumber;
/* The cast from unsigned long to signed long is on purpose. */
lDistance = ( int32_t ) ulSequenceNumberDiff;

if( lDistance <= 0 )
{
Expand Down

0 comments on commit 05b4d4f

Please sign in to comment.