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: 91232 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D13BB1007D1 for ; Thu, 14 Apr 2011 23:12:25 +1000 (EST) Received: from localhost ([::1]:54989 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAMLM-0004FC-On for incoming@patchwork.ozlabs.org; Thu, 14 Apr 2011 09:12:20 -0400 Received: from eggs.gnu.org ([140.186.70.92]:37948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAMLA-00048c-Bf for qemu-devel@nongnu.org; Thu, 14 Apr 2011 09:12:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QAML6-000612-Dx for qemu-devel@nongnu.org; Thu, 14 Apr 2011 09:12:08 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:54679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAML6-0005zg-79; Thu, 14 Apr 2011 09:12:04 -0400 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 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 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: qemu-trivial@nongnu.org, patches@linaro.org Subject: [Qemu-devel] [PATCH] tests/test-mmap.c: Check mmap() return value before using it X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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);