From patchwork Mon Jul 2 18:06:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 168622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C68012C0081 for ; Tue, 3 Jul 2012 04:06:22 +1000 (EST) Received: from localhost ([::1]:43859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sll0u-000185-Kt for incoming@patchwork.ozlabs.org; Mon, 02 Jul 2012 14:06:20 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sll0a-0000MR-7W for qemu-devel@nongnu.org; Mon, 02 Jul 2012 14:06:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sll0Y-0001n8-CP for qemu-devel@nongnu.org; Mon, 02 Jul 2012 14:05:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57474) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sll0Y-0001mu-4S for qemu-devel@nongnu.org; Mon, 02 Jul 2012 14:05:58 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q62I5mkk004045 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 2 Jul 2012 14:05:48 -0400 Received: from blackpad.lan.raisama.net (vpn1-4-141.gru2.redhat.com [10.97.4.141]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q62I5lKV023267; Mon, 2 Jul 2012 14:05:48 -0400 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id B600E200E41; Mon, 2 Jul 2012 15:06:40 -0300 (BRT) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Mon, 2 Jul 2012 15:06:36 -0300 Message-Id: <1341252398-12268-5-git-send-email-ehabkost@redhat.com> In-Reply-To: <1341252398-12268-1-git-send-email-ehabkost@redhat.com> References: <1341252398-12268-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Bill Gray , Andrea Arcangeli , Andre Przywara , kvm@vger.kernel.org, Bharata B Rao Subject: [Qemu-devel] [PATCH 4/6] file_ram_alloc: change length argument to size_t (v2) 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 While we are at it, rename it to "length", as "memory" doesn't mean anything. Changes v1 -> v2: - Rebase after coding style changes Signed-off-by: Eduardo Habkost --- exec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index d856325..1e98244 100644 --- a/exec.c +++ b/exec.c @@ -2357,7 +2357,7 @@ static long gethugepagesize(const char *path) } static void *file_ram_alloc(RAMBlock *block, - ram_addr_t memory, + size_t length, const char *path) { gchar *filename; @@ -2373,7 +2373,7 @@ static void *file_ram_alloc(RAMBlock *block, return NULL; } - if (memory < hpagesize) { + if (length < hpagesize) { return NULL; } @@ -2392,7 +2392,7 @@ static void *file_ram_alloc(RAMBlock *block, unlink(filename); g_free(filename); - memory = (memory + hpagesize - 1) & ~(hpagesize - 1); + length = (length + hpagesize - 1) & ~(hpagesize - 1); /* * ftruncate is not supported by hugetlbfs in older @@ -2400,7 +2400,7 @@ static void *file_ram_alloc(RAMBlock *block, * If anything goes wrong with it under other filesystems, * mmap will fail. */ - if (ftruncate(fd, memory)) { + if (ftruncate(fd, length)) { perror("ftruncate"); } @@ -2410,9 +2410,9 @@ static void *file_ram_alloc(RAMBlock *block, * to sidestep this quirk. */ flags = mem_prealloc ? MAP_POPULATE | MAP_SHARED : MAP_PRIVATE; - area = mmap(0, memory, PROT_READ | PROT_WRITE, flags, fd, 0); + area = mmap(0, length, PROT_READ | PROT_WRITE, flags, fd, 0); #else - area = mmap(0, memory, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); + area = mmap(0, length, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); #endif if (area == MAP_FAILED) { perror("file_ram_alloc: can't mmap RAM pages");