mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Fix cast alignment warning in heap_4.c and heap_5.c (#771)
* Fix cast alignment warning --------- Co-authored-by: Soren Ptak <ptaksoren@gmail.com> Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
This commit is contained in:
parent
1aaa318f1c
commit
231278eded
|
@ -444,7 +444,6 @@ void * pvPortCalloc( size_t xNum,
|
||||||
static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
|
static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
|
||||||
{
|
{
|
||||||
BlockLink_t * pxFirstFreeBlock;
|
BlockLink_t * pxFirstFreeBlock;
|
||||||
uint8_t * pucAlignedHeap;
|
|
||||||
portPOINTER_SIZE_TYPE uxAddress;
|
portPOINTER_SIZE_TYPE uxAddress;
|
||||||
size_t xTotalHeapSize = configTOTAL_HEAP_SIZE;
|
size_t xTotalHeapSize = configTOTAL_HEAP_SIZE;
|
||||||
|
|
||||||
|
@ -458,8 +457,6 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
|
||||||
xTotalHeapSize -= ( size_t ) ( uxAddress - ( portPOINTER_SIZE_TYPE ) ucHeap );
|
xTotalHeapSize -= ( size_t ) ( uxAddress - ( portPOINTER_SIZE_TYPE ) ucHeap );
|
||||||
}
|
}
|
||||||
|
|
||||||
pucAlignedHeap = ( uint8_t * ) uxAddress;
|
|
||||||
|
|
||||||
#if ( configENABLE_HEAP_PROTECTOR == 1 )
|
#if ( configENABLE_HEAP_PROTECTOR == 1 )
|
||||||
{
|
{
|
||||||
vApplicationGetRandomHeapCanary( &( xHeapCanary ) );
|
vApplicationGetRandomHeapCanary( &( xHeapCanary ) );
|
||||||
|
@ -468,12 +465,12 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
|
||||||
|
|
||||||
/* xStart is used to hold a pointer to the first item in the list of free
|
/* xStart is used to hold a pointer to the first item in the list of free
|
||||||
* blocks. The void cast is used to prevent compiler warnings. */
|
* blocks. The void cast is used to prevent compiler warnings. */
|
||||||
xStart.pxNextFreeBlock = ( void * ) heapPROTECT_BLOCK_POINTER( pucAlignedHeap );
|
xStart.pxNextFreeBlock = ( void * ) heapPROTECT_BLOCK_POINTER( uxAddress );
|
||||||
xStart.xBlockSize = ( size_t ) 0;
|
xStart.xBlockSize = ( size_t ) 0;
|
||||||
|
|
||||||
/* pxEnd is used to mark the end of the list of free blocks and is inserted
|
/* pxEnd is used to mark the end of the list of free blocks and is inserted
|
||||||
* at the end of the heap space. */
|
* at the end of the heap space. */
|
||||||
uxAddress = ( portPOINTER_SIZE_TYPE ) ( pucAlignedHeap + xTotalHeapSize );
|
uxAddress = ( portPOINTER_SIZE_TYPE ) ( uxAddress + xTotalHeapSize );
|
||||||
uxAddress -= ( portPOINTER_SIZE_TYPE ) xHeapStructSize;
|
uxAddress -= ( portPOINTER_SIZE_TYPE ) xHeapStructSize;
|
||||||
uxAddress &= ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK );
|
uxAddress &= ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK );
|
||||||
pxEnd = ( BlockLink_t * ) uxAddress;
|
pxEnd = ( BlockLink_t * ) uxAddress;
|
||||||
|
@ -482,7 +479,7 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
|
||||||
|
|
||||||
/* To start with there is a single free block that is sized to take up the
|
/* To start with there is a single free block that is sized to take up the
|
||||||
* entire heap space, minus the space taken by pxEnd. */
|
* entire heap space, minus the space taken by pxEnd. */
|
||||||
pxFirstFreeBlock = ( BlockLink_t * ) pucAlignedHeap;
|
pxFirstFreeBlock = ( BlockLink_t * ) uxAddress;
|
||||||
pxFirstFreeBlock->xBlockSize = ( size_t ) ( uxAddress - ( portPOINTER_SIZE_TYPE ) pxFirstFreeBlock );
|
pxFirstFreeBlock->xBlockSize = ( size_t ) ( uxAddress - ( portPOINTER_SIZE_TYPE ) pxFirstFreeBlock );
|
||||||
pxFirstFreeBlock->pxNextFreeBlock = heapPROTECT_BLOCK_POINTER( pxEnd );
|
pxFirstFreeBlock->pxNextFreeBlock = heapPROTECT_BLOCK_POINTER( pxEnd );
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@
|
||||||
|
|
||||||
#define heapPROTECT_BLOCK_POINTER( pxBlock ) ( pxBlock )
|
#define heapPROTECT_BLOCK_POINTER( pxBlock ) ( pxBlock )
|
||||||
|
|
||||||
#define heapVALIDATE_BLOCK_POINTER( pxBlock ) ( pxBlock )
|
#define heapVALIDATE_BLOCK_POINTER( pxBlock )
|
||||||
|
|
||||||
#endif /* configENABLE_HEAP_PROTECTOR */
|
#endif /* configENABLE_HEAP_PROTECTOR */
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) /* PRIVI
|
||||||
if( ( xAddress & portBYTE_ALIGNMENT_MASK ) != 0 )
|
if( ( xAddress & portBYTE_ALIGNMENT_MASK ) != 0 )
|
||||||
{
|
{
|
||||||
xAddress += ( portBYTE_ALIGNMENT - 1 );
|
xAddress += ( portBYTE_ALIGNMENT - 1 );
|
||||||
xAddress &= ~portBYTE_ALIGNMENT_MASK;
|
xAddress &= ~( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK;
|
||||||
|
|
||||||
/* Adjust the size for the bytes lost to alignment. */
|
/* Adjust the size for the bytes lost to alignment. */
|
||||||
xTotalRegionSize -= ( size_t ) ( xAddress - ( portPOINTER_SIZE_TYPE ) pxHeapRegion->pucStartAddress );
|
xTotalRegionSize -= ( size_t ) ( xAddress - ( portPOINTER_SIZE_TYPE ) pxHeapRegion->pucStartAddress );
|
||||||
|
|
Loading…
Reference in a new issue