From patchwork Thu Apr 14 13:11:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1018 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:21 -0000 Delivered-To: patches@linaro.org Received: by 10.68.59.138 with SMTP id z10cs44109pbq; Thu, 14 Apr 2011 06:12:00 -0700 (PDT) Received: by 10.216.62.67 with SMTP id x45mr6435201wec.92.1302786719734; Thu, 14 Apr 2011 06:11:59 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk [81.2.115.146]) by mx.google.com with ESMTPS id m11si2955378wer.110.2011.04.14.06.11.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 14 Apr 2011 06:11:59 -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 1QAMKy-0005S4-9T; Thu, 14 Apr 2011 14:11:56 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, patches@linaro.org Subject: [PATCH] tests/test-mmap.c: Check mmap() return value before using it Date: Thu, 14 Apr 2011 14:11:56 +0100 Message-Id: <1302786716-20933-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 Correct the position of a "stop if MAP_FAILED" check in the mmap() tests, so that if mmap() does fail we print a failure message rather than segfaulting inside memcpy(). Signed-off-by: Peter Maydell --- tests/test-mmap.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tests/test-mmap.c b/tests/test-mmap.c index fcb365f..c578e25 100644 --- a/tests/test-mmap.c +++ b/tests/test-mmap.c @@ -164,6 +164,7 @@ void check_aligned_anonymous_unfixed_colliding_mmaps(void) nlen = pagesize * 8; p3 = mmap(NULL, nlen, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + fail_unless (p3 != MAP_FAILED); /* Check if the mmaped areas collide. */ if (p3 < p2 @@ -174,7 +175,6 @@ void check_aligned_anonymous_unfixed_colliding_mmaps(void) /* Make sure we get pages aligned with the pagesize. The target expects this. */ - fail_unless (p3 != MAP_FAILED); p = (uintptr_t) p3; fail_unless ((p & pagemask) == 0); munmap (p2, pagesize);