Skip to content

Commit 37215ae

Browse files
committed
Fix cast alignment warning
1 parent af2904b commit 37215ae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

portable/MemMang/heap_4.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ void * pvPortCalloc( size_t xNum,
444444
static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
445445
{
446446
BlockLink_t * pxFirstFreeBlock;
447-
uint8_t * pucAlignedHeap;
447+
void * pvAlignedHeap;
448448
portPOINTER_SIZE_TYPE uxAddress;
449449
size_t xTotalHeapSize = configTOTAL_HEAP_SIZE;
450450

@@ -458,7 +458,7 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
458458
xTotalHeapSize -= ( size_t ) ( uxAddress - ( portPOINTER_SIZE_TYPE ) ucHeap );
459459
}
460460

461-
pucAlignedHeap = ( uint8_t * ) uxAddress;
461+
pvAlignedHeap = ( uint8_t * ) uxAddress;
462462

463463
#if ( configENABLE_HEAP_PROTECTOR == 1 )
464464
{
@@ -468,12 +468,12 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
468468

469469
/* xStart is used to hold a pointer to the first item in the list of free
470470
* blocks. The void cast is used to prevent compiler warnings. */
471-
xStart.pxNextFreeBlock = ( void * ) heapPROTECT_BLOCK_POINTER( pucAlignedHeap );
471+
xStart.pxNextFreeBlock = ( void * ) heapPROTECT_BLOCK_POINTER( pvAlignedHeap );
472472
xStart.xBlockSize = ( size_t ) 0;
473473

474474
/* pxEnd is used to mark the end of the list of free blocks and is inserted
475475
* at the end of the heap space. */
476-
uxAddress = ( portPOINTER_SIZE_TYPE ) ( pucAlignedHeap + xTotalHeapSize );
476+
uxAddress = ( portPOINTER_SIZE_TYPE ) ( ( ( uint8_t * ) pvAlignedHeap ) + xTotalHeapSize );
477477
uxAddress -= ( portPOINTER_SIZE_TYPE ) xHeapStructSize;
478478
uxAddress &= ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK );
479479
pxEnd = ( BlockLink_t * ) uxAddress;
@@ -482,7 +482,7 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
482482

483483
/* To start with there is a single free block that is sized to take up the
484484
* entire heap space, minus the space taken by pxEnd. */
485-
pxFirstFreeBlock = ( BlockLink_t * ) pucAlignedHeap;
485+
pxFirstFreeBlock = ( BlockLink_t * ) pvAlignedHeap;
486486
pxFirstFreeBlock->xBlockSize = ( size_t ) ( uxAddress - ( portPOINTER_SIZE_TYPE ) pxFirstFreeBlock );
487487
pxFirstFreeBlock->pxNextFreeBlock = heapPROTECT_BLOCK_POINTER( pxEnd );
488488

0 commit comments

Comments
 (0)