Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-josi-aws committed Jun 3, 2024
1 parent 6ca23ec commit 2e7d4e6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 33 deletions.
11 changes: 6 additions & 5 deletions source/FreeRTOS_Sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -3891,11 +3891,12 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket )
if( pxParentSocket->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED )
{
pxClientSocket = pxParentSocket->u.xTCP.pxPeerSocket;

if( pxClientSocket != NULL )
{
FreeRTOS_printf( ( "prvAcceptWaitClient: client %p parent %p\n",
( void * ) pxClientSocket, ( void * ) pxParentSocket ) );
}
{
FreeRTOS_printf( ( "prvAcceptWaitClient: client %p parent %p\n",
( void * ) pxClientSocket, ( void * ) pxParentSocket ) );
}
}
else
{
Expand All @@ -3904,14 +3905,14 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket )

if( pxClientSocket != NULL )
{

/* Is it still not taken ? */
if( pxClientSocket->u.xTCP.bits.bPassAccept != pdFALSE_UNSIGNED )
{
if( pxParentSocket->u.xTCP.pxPeerSocket != NULL )
{
pxParentSocket->u.xTCP.pxPeerSocket = NULL;
}

pxClientSocket->u.xTCP.bits.bPassAccept = pdFALSE_UNSIGNED;
}
else
Expand Down
46 changes: 24 additions & 22 deletions source/FreeRTOS_TCP_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@

static BaseType_t vTCPRemoveTCPChild( const FreeRTOS_Socket_t * pxChildSocket )
{
BaseType_t xReturn = pdFALSE;
const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
BaseType_t xReturn = pdFALSE;
const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );

/* MISRA Ref 11.3.1 [Misaligned access] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
Expand All @@ -286,21 +286,23 @@

while( pxIterator != pxEnd )
{
FreeRTOS_Socket_t * pxSocket;
FreeRTOS_Socket_t * pxSocket;
pxSocket = ( ( FreeRTOS_Socket_t * ) listGET_LIST_ITEM_OWNER( pxIterator ) );
pxIterator = ( ListItem_t * ) listGET_NEXT( pxIterator );
if( ( pxSocket != pxChildSocket ) && ( pxSocket->usLocalPort == pxChildSocket->usLocalPort ) )
{
if( pxSocket->u.xTCP.pxPeerSocket == pxChildSocket ) /**< for server socket: child, for child socket: parent */
{
pxSocket->u.xTCP.pxPeerSocket = NULL;
xReturn = pdTRUE;
break;
}
}

if( ( pxSocket != pxChildSocket ) && ( pxSocket->usLocalPort == pxChildSocket->usLocalPort ) )
{
if( pxSocket->u.xTCP.pxPeerSocket == pxChildSocket ) /**< for server socket: child, for child socket: parent */
{
pxSocket->u.xTCP.pxPeerSocket = NULL;
xReturn = pdTRUE;
break;
}
}
}
return xReturn;
}

return xReturn;
}

/**
* @brief Changing to a new state. Centralised here to do specific actions such as
Expand Down Expand Up @@ -485,14 +487,14 @@
/* Socket goes to status eCLOSED because of a RST.
* When nobody owns the socket yet, delete it. */
FreeRTOS_printf( ( "vTCPStateChange: Closing (Queued %d, Accept %d Reuse %d)\n",
pxSocket->u.xTCP.bits.bPassQueued,
pxSocket->u.xTCP.bits.bPassAccept,
pxSocket->u.xTCP.bits.bReuseSocket ) );
pxSocket->u.xTCP.bits.bPassQueued,
pxSocket->u.xTCP.bits.bPassAccept,
pxSocket->u.xTCP.bits.bReuseSocket ) );
FreeRTOS_printf( ( "vTCPStateChange: me %p parent %p peer %p clear %d\n",
( void * ) pxSocket,
( void * ) xParent,
xParent ? ( void * ) xParent->u.xTCP.pxPeerSocket : NULL,
( int ) xMustClear ) );
( void * ) pxSocket,
( void * ) xParent,
xParent ? ( void * ) xParent->u.xTCP.pxPeerSocket : NULL,
( int ) xMustClear ) );

vTaskSuspendAll();
{
Expand All @@ -513,7 +515,7 @@
}
( void ) xTaskResumeAll();
FreeRTOS_printf( ( "vTCPStateChange: xHasCleared = %d\n",
( int ) xHasCleared ) );
( int ) xHasCleared ) );
}

if( ( eTCPState == eCLOSE_WAIT ) && ( pxSocket->u.xTCP.bits.bReuseSocket == pdTRUE_UNSIGNED ) )
Expand Down
3 changes: 2 additions & 1 deletion source/FreeRTOS_TCP_State_Handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,9 +1020,10 @@
#endif /* if ( ipconfigTCP_HANG_PROTECTION == 1 ) */

pxSocket->u.xTCP.usChildCount++;

if( pxSocket->u.xTCP.pxPeerSocket == NULL )
{
pxSocket->u.xTCP.pxPeerSocket = pxNewSocket;
pxSocket->u.xTCP.pxPeerSocket = pxNewSocket;
}

FreeRTOS_debug_printf( ( "Gain: Socket %u now has %u / %u child%s me: %p parent: %p peer: %p\n",
Expand Down
10 changes: 5 additions & 5 deletions test/unit-test/FreeRTOS_TCP_IP/FreeRTOS_TCP_IP_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ void test_vTCPStateChange_EstablishedState_ChildSocket2( void )
xIsCallingFromIPTask_ExpectAndReturn( pdTRUE );

vSocketClose_ExpectAnyArgsAndReturn( NULL );

xTaskResumeAll_ExpectAndReturn( 0 );
xTaskGetTickCount_ExpectAndReturn( xTickCountAck );
xTaskGetTickCount_ExpectAndReturn( xTickCountAlive );
Expand Down Expand Up @@ -2613,7 +2613,7 @@ void test_xTCPCheckNewClient_Found( void )
}

/**
* @brief This function validates the case when the child socket is found in
* @brief This function validates the case when the child socket is found in
* the bounded socket list.
*/
void test_vTCPRemoveTCPChild_ChildSocketFound( void )
Expand Down Expand Up @@ -2646,7 +2646,7 @@ void test_vTCPRemoveTCPChild_ChildSocketFound( void )
}

/**
* @brief This function validates the case when the child socket is found in
* @brief This function validates the case when the child socket is found in
* the bounded socket list but non matching port number.
*/
void test_vTCPRemoveTCPChild_ChildSocketFound_DifferentPortNumber( void )
Expand Down Expand Up @@ -2679,7 +2679,7 @@ void test_vTCPRemoveTCPChild_ChildSocketFound_DifferentPortNumber( void )
}

/**
* @brief This function validates the case when no child socket is found in
* @brief This function validates the case when no child socket is found in
* the bounded socket list but matching port number is present.
*/
void test_vTCPRemoveTCPChild_NoChildSocketFound_MatchingPortNumber( void )
Expand Down Expand Up @@ -2709,4 +2709,4 @@ void test_vTCPRemoveTCPChild_NoChildSocketFound_MatchingPortNumber( void )
pxSocket->usLocalPort = FreeRTOS_ntohs( 40000 );
Return = vTCPRemoveTCPChild( &xChildSocket );
TEST_ASSERT_EQUAL( pdFALSE, Return );
}
}

0 comments on commit 2e7d4e6

Please sign in to comment.