Skip to content

Commit 43d9881

Browse files
committed
Fix false positive array-bounds warning
1 parent 07fa6b0 commit 43d9881

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

source/FreeRTOS_DNS_Callback.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
{
5959
BaseType_t xResult = pdFALSE;
6060
const ListItem_t * pxIterator;
61-
const ListItem_t * xEnd = listGET_END_MARKER( &xCallbackList );
61+
const ListItem_t * pxEnd = listGET_END_MARKER( &xCallbackList );
6262
TickType_t uxIdentifier = ( TickType_t ) pxSet->pxDNSMessageHeader->usIdentifier;
6363

6464
/* While iterating through the list, the scheduler is suspended.
@@ -69,8 +69,8 @@
6969

7070
vTaskSuspendAll();
7171
{
72-
for( pxIterator = ( const ListItem_t * ) listGET_NEXT( xEnd );
73-
pxIterator != ( const ListItem_t * ) xEnd;
72+
for( pxIterator = ( const ListItem_t * ) listGET_HEAD_ENTRY( &xCallbackList );
73+
pxIterator != ( const ListItem_t * ) pxEnd;
7474
pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator ) )
7575
{
7676
BaseType_t xMatching;
@@ -194,7 +194,7 @@
194194
void vDNSCheckCallBack( void * pvSearchID )
195195
{
196196
const ListItem_t * pxIterator;
197-
const ListItem_t * xEnd = listGET_END_MARKER( &xCallbackList );
197+
const ListItem_t * pxEnd = listGET_END_MARKER( &xCallbackList );
198198

199199
/* When a DNS-search times out, the call-back function shall
200200
* be called. Store theses item in a temporary list.
@@ -206,8 +206,8 @@
206206

207207
vTaskSuspendAll();
208208
{
209-
for( pxIterator = ( const ListItem_t * ) listGET_NEXT( xEnd );
210-
pxIterator != xEnd; )
209+
for( pxIterator = ( const ListItem_t * ) listGET_HEAD_ENTRY( &xCallbackList );
210+
pxIterator != pxEnd; )
211211
{
212212
DNSCallback_t * pxCallback = ( ( DNSCallback_t * ) listGET_LIST_ITEM_OWNER( pxIterator ) );
213213
/* Move to the next item because we might remove this item */
@@ -239,10 +239,10 @@
239239
if( listLIST_IS_EMPTY( &xTempList ) == pdFALSE )
240240
{
241241
/* There is at least one item in xTempList which must be removed and deleted. */
242-
xEnd = listGET_END_MARKER( &xTempList );
242+
pxEnd = listGET_END_MARKER( &xTempList );
243243

244-
for( pxIterator = ( const ListItem_t * ) listGET_NEXT( xEnd );
245-
pxIterator != xEnd;
244+
for( pxIterator = ( const ListItem_t * ) listGET_HEAD_ENTRY( &xTempList );
245+
pxIterator != pxEnd;
246246
)
247247
{
248248
DNSCallback_t * pxCallback = ( ( DNSCallback_t * ) listGET_LIST_ITEM_OWNER( pxIterator ) );

source/FreeRTOS_Sockets.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,7 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket )
22852285

22862286
if( pxSocketToDelete->u.xTCP.eTCPState == eTCP_LISTEN )
22872287
{
2288-
pxIterator = listGET_NEXT( pxEnd );
2288+
pxIterator = listGET_HEAD_ENTRY( &xBoundTCPSocketsList );
22892289

22902290
while( pxIterator != pxEnd )
22912291
{
@@ -2309,7 +2309,7 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket )
23092309
}
23102310
else
23112311
{
2312-
for( pxIterator = listGET_NEXT( pxEnd );
2312+
for( pxIterator = listGET_HEAD_ENTRY( &xBoundTCPSocketsList );
23132313
pxIterator != pxEnd;
23142314
pxIterator = listGET_NEXT( pxIterator ) )
23152315
{
@@ -3054,7 +3054,7 @@ static const ListItem_t * pxListFindListItemWithValue( const List_t * pxList,
30543054
/* coverity[misra_c_2012_rule_11_3_violation] */
30553055
const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( pxList->xListEnd ) );
30563056

3057-
for( pxIterator = listGET_NEXT( pxEnd );
3057+
for( pxIterator = listGET_HEAD_ENTRY( pxList );
30583058
pxIterator != pxEnd;
30593059
pxIterator = listGET_NEXT( pxIterator ) )
30603060
{
@@ -4961,7 +4961,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket )
49614961

49624962
( void ) ulLocalIP;
49634963

4964-
for( pxIterator = listGET_NEXT( pxEnd );
4964+
for( pxIterator = listGET_HEAD_ENTRY( &xBoundTCPSocketsList );
49654965
pxIterator != pxEnd;
49664966
pxIterator = listGET_NEXT( pxIterator ) )
49674967
{
@@ -6085,13 +6085,15 @@ BaseType_t FreeRTOS_GetIPType( ConstSocket_t xSocket )
60856085
{
60866086
const ListItem_t * pxIterator;
60876087
const ListItem_t * pxEnd;
6088+
const List_t * pxList;
60886089

60896090
if( xRound == 0 )
60906091
{
60916092
/* MISRA Ref 11.3.1 [Misaligned access] */
60926093
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
60936094
/* coverity[misra_c_2012_rule_11_3_violation] */
60946095
pxEnd = ( ( const ListItem_t * ) &( xBoundUDPSocketsList.xListEnd ) );
6096+
pxList = &xBoundUDPSocketsList;
60956097
}
60966098

60976099
#if ipconfigUSE_TCP == 1
@@ -6101,10 +6103,11 @@ BaseType_t FreeRTOS_GetIPType( ConstSocket_t xSocket )
61016103
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
61026104
/* coverity[misra_c_2012_rule_11_3_violation] */
61036105
pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
6106+
pxList = &xBoundTCPSocketsList;
61046107
}
61056108
#endif /* ipconfigUSE_TCP == 1 */
61066109

6107-
for( pxIterator = listGET_NEXT( pxEnd );
6110+
for( pxIterator = listGET_HEAD_ENTRY( pxList );
61086111
pxIterator != pxEnd;
61096112
pxIterator = listGET_NEXT( pxIterator ) )
61106113
{

0 commit comments

Comments
 (0)