From eb4819de656c6f0fbbb1bab9532c0e5ee94d5dcf Mon Sep 17 00:00:00 2001 From: Archit Gupta Date: Wed, 30 Nov 2022 16:08:28 -0800 Subject: [PATCH] Fix array-bounds compiler warning on gcc11+ in list.h listGET_OWNER_OF_NEXT_ENTRY computes `( pxConstList )->pxIndex->pxNext` after verifying that `( pxConstList )->pxIndex` points to `xListEnd`, which due to being a MiniListItem_t, can be shorter than a ListItem_t. Thus, `( pxConstList )->pxIndex` is a `ListItem_t *` that extends past the end of the `List_t` whose `xListEnd` it points to. This is fixed by accessing `pxNext` through a `MiniListItem_t` instead. --- include/list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/list.h b/include/list.h index 11241b68687..248212260a1 100644 --- a/include/list.h +++ b/include/list.h @@ -290,7 +290,7 @@ typedef struct xLIST ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \ { \ - ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ + ( pxConstList )->pxIndex = ( pxConstList )->xListEnd.pxNext; \ } \ ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ }