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

index 0371089b982c47e14a3cf0160a86359d6870335c..7fde10e8f36254685058e153c93a39c4d4a28a94 100644 (file)
@@ -370,7 +370,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
         TaskState *ts = env->opaque;
         /* Allocate the heap using sbrk.  */
         if (!ts->heap_limit) {
-            long ret;
+            abi_ulong ret;
             uint32_t size;
             uint32_t base;
 
@@ -379,8 +379,9 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
             /* Try a big heap, and reduce the size if that fails.  */
             for (;;) {
                 ret = do_brk(base + size);
-                if (ret != -1)
+                if (ret >= (base + size)) {
                     break;
+                }
                 size >>= 1;
             }
             ts->heap_limit = base + size;