From 2cdd0e5e55b8fae5c80943ec09dc960457aef34a Mon Sep 17 00:00:00 2001 From: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Thu, 20 Jul 2023 16:21:17 +0530 Subject: [PATCH] Add `-Wconversion` in CMakeLists.txt (#712) Also fix warnings generated by this flag. Signed-off-by: Gaurav Aggarwal --- CMakeLists.txt | 1 + portable/MemMang/heap_4.c | 2 +- portable/MemMang/heap_5.c | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6faa9316736..678b6a6f5d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,6 +260,7 @@ target_compile_options(freertos_kernel PRIVATE $<$:-Wextra> $<$:-Wpedantic> $<$:-Werror> + $<$:-Wconversion> $<$:-Weverything> # Suppressions required to build clean with clang. diff --git a/portable/MemMang/heap_4.c b/portable/MemMang/heap_4.c index c7a8209ed2b..c82933e6692 100644 --- a/portable/MemMang/heap_4.c +++ b/portable/MemMang/heap_4.c @@ -421,7 +421,7 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */ /* pxEnd is used to mark the end of the list of free blocks and is inserted * at the end of the heap space. */ uxAddress = ( portPOINTER_SIZE_TYPE ) ( pucAlignedHeap + xTotalHeapSize ); - uxAddress -= xHeapStructSize; + uxAddress -= ( portPOINTER_SIZE_TYPE ) xHeapStructSize; uxAddress &= ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ); pxEnd = ( BlockLink_t * ) uxAddress; pxEnd->xBlockSize = 0; diff --git a/portable/MemMang/heap_5.c b/portable/MemMang/heap_5.c index db9e1eb37ad..bd641dcdf21 100644 --- a/portable/MemMang/heap_5.c +++ b/portable/MemMang/heap_5.c @@ -508,7 +508,7 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) configASSERT( pxEnd != NULL ); /* Check blocks are passed in with increasing start addresses. */ - configASSERT( xAddress > ( size_t ) pxEnd ); + configASSERT( ( size_t ) xAddress > ( size_t ) pxEnd ); } /* Remember the location of the end marker in the previous region, if @@ -517,9 +517,9 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) /* pxEnd is used to mark the end of the list of free blocks and is * inserted at the end of the region space. */ - xAddress = xAlignedHeap + xTotalRegionSize; - xAddress -= xHeapStructSize; - xAddress &= ~( ( size_t ) portBYTE_ALIGNMENT_MASK ); + xAddress = xAlignedHeap + ( portPOINTER_SIZE_TYPE ) xTotalRegionSize; + xAddress -= ( portPOINTER_SIZE_TYPE ) xHeapStructSize; + xAddress &= ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ); pxEnd = ( BlockLink_t * ) xAddress; pxEnd->xBlockSize = 0; pxEnd->pxNextFreeBlock = NULL;