]> git.proxmox.com Git - qemu.git/commitdiff
arm-semi.c: Use correct check for failure of do_brk()
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 18 Apr 2011 15:34:25 +0000 (16:34 +0100)
committerRiku Voipio <riku.voipio@iki.fi>
Tue, 21 Jun 2011 17:29:01 +0000 (20:29 +0300)
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 <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
arm-semi.c

index e9e6f8993f11bc630e3b9e8825caea068c7065f0..5a62d03b36e0c5b260fd4bce0728f3f9b8f4abcd 100644 (file)
@@ -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;