From 206ae74aea5593f5f5bad769a6b4f101f17bc6fd Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Mon, 18 Apr 2011 16:34:25 +0100 Subject: [PATCH] arm-semi.c: Use correct check for failure of do_brk() In the ARM semihosting implementation of SYS_HEAPINFO, use the correct check for whether do_brk() has failed -- it does not return -1 but the previous value of the break limit. Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- arm-semi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arm-semi.c b/arm-semi.c index e9e6f8993f..5a62d03b36 100644 --- a/arm-semi.c +++ b/arm-semi.c @@ -440,15 +440,16 @@ uint32_t do_arm_semihosting(CPUState *env) /* Some C libraries assume the heap immediately follows .bss, so allocate it using sbrk. */ if (!ts->heap_limit) { - long ret; + abi_ulong ret; ts->heap_base = do_brk(0); limit = ts->heap_base + ARM_ANGEL_HEAP_SIZE; /* Try a big heap, and reduce the size if that fails. */ for (;;) { ret = do_brk(limit); - if (ret != -1) + if (ret >= limit) { break; + } limit = (ts->heap_base >> 1) + (limit >> 1); } ts->heap_limit = limit; -- 2.11.4.GIT