From patchwork Mon Apr 18 15:34:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1077 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 r20cs38565qai; Mon, 18 Apr 2011 08:34:31 -0700 (PDT) Received: by 10.213.26.213 with SMTP id f21mr2178446ebc.70.1303140870586; 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 u49si12308350eeh.38.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-0007dr-Up; Mon, 18 Apr 2011 16:34:26 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: Riku Voipio , patches@linaro.org Subject: [PATCH 2/3] arm-semi.c: Use correct check for failure of do_brk() Date: Mon, 18 Apr 2011 16:34:25 +0100 Message-Id: <1303140866-29348-3-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 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 --- arm-semi.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arm-semi.c b/arm-semi.c index e9e6f89..5a62d03 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;