From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:38217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBqfD-0006JW-41 for qemu-devel@nongnu.org; Mon, 18 Apr 2011 11:47:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QBqfB-0000IL-KY for qemu-devel@nongnu.org; Mon, 18 Apr 2011 11:46:59 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:49709) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBqfB-0000IH-AC for qemu-devel@nongnu.org; Mon, 18 Apr 2011 11:46:57 -0400 From: Peter Maydell Date: Mon, 18 Apr 2011 16:34:26 +0100 Message-Id: <1303140866-29348-4-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1303140866-29348-1-git-send-email-peter.maydell@linaro.org> References: <1303140866-29348-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 3/3] m68k-semi.c: Use correct check for failure of do_brk() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio , patches@linaro.org 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 --- m68k-semi.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/m68k-semi.c b/m68k-semi.c index 0371089..7fde10e 100644 --- a/m68k-semi.c +++ b/m68k-semi.c @@ -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; -- 1.7.1