From patchwork Mon Apr 18 15:34:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1079 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:48:54 -0000 Delivered-To: patches@linaro.org Received: by 10.224.67.148 with SMTP id r20cs38566qai; Mon, 18 Apr 2011 08:34:31 -0700 (PDT) Received: by 10.227.163.13 with SMTP id y13mr5216503wbx.56.1303140870643; Mon, 18 Apr 2011 08:34:30 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk [81.2.115.146]) by mx.google.com with ESMTPS id j7si10332152wbj.25.2011.04.18.08.34.28 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Apr 2011 08:34:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1QBqT4-0007dt-VO; Mon, 18 Apr 2011 16:34:26 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: Riku Voipio , patches@linaro.org Subject: [PATCH 3/3] m68k-semi.c: Use correct check for failure of do_brk() Date: Mon, 18 Apr 2011 16:34:26 +0100 Message-Id: <1303140866-29348-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1303140866-29348-1-git-send-email-peter.maydell@linaro.org> References: <1303140866-29348-1-git-send-email-peter.maydell@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;