This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 69c26310b553be83a7205c7334cbde6a4abbc743
Author: ganjing <[email protected]>
AuthorDate: Thu Aug 7 15:00:11 2025 +0800

    sim/sim_ummheap.c: fix incompatible_cast bug
    
    In the following code:
    "while (!atomic_try_cmpxchg(&heap->usmblks, &usmblks, uordblks))"
    
    The pointer &usmblks points to an object with an effective type of unsigned 
long (64-bit, unsigned),
    but is dereferenced as the narrower type int (32-bit, signed).
    This may lead to unexpected results.
    
    Signed-off-by: ganjing <[email protected]>
---
 arch/sim/src/sim/sim_ummheap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sim/src/sim/sim_ummheap.c b/arch/sim/src/sim/sim_ummheap.c
index 0c1115298ec..7a0addd0b19 100644
--- a/arch/sim/src/sim/sim_ummheap.c
+++ b/arch/sim/src/sim/sim_ummheap.c
@@ -209,8 +209,8 @@ static void update_stats(struct mm_heap_s *heap, void *mem, 
size_t size,
 {
   struct mm_allocnode_s *node;
   irqstate_t flags;
-  size_t uordblks;
-  size_t usmblks;
+  int uordblks;
+  int usmblks;
 
   node = (struct mm_allocnode_s *)((uintptr_t)mem - MM_ALLOCNODE_SIZE);
   flags = spin_lock_irqsave(&heap->lock);

Reply via email to