From patchwork Thu May 27 14:20:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 53761 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6E66EB7D1D for ; Fri, 28 May 2010 00:31:23 +1000 (EST) Received: from localhost ([127.0.0.1]:38276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHe7E-0000pN-CP for incoming@patchwork.ozlabs.org; Thu, 27 May 2010 10:31:20 -0400 Received: from [140.186.70.92] (port=58772 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHdx9-0007oo-Hp for qemu-devel@nongnu.org; Thu, 27 May 2010 10:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHdx8-0008NU-5G for qemu-devel@nongnu.org; Thu, 27 May 2010 10:20:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11843) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHdx7-0008NP-Tv for qemu-devel@nongnu.org; Thu, 27 May 2010 10:20:54 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4REKp8N012095 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 May 2010 10:20:51 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4REKiaL009096; Thu, 27 May 2010 10:20:49 -0400 From: Jes.Sorensen@redhat.com To: anthony@codemonkey.ws Date: Thu, 27 May 2010 16:20:31 +0200 Message-Id: <1274970033-24093-3-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1274970033-24093-1-git-send-email-Jes.Sorensen@redhat.com> References: <1274970033-24093-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Jes Sorensen , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 2/4] Cleanup: Be consistent and use BDRV_SECTOR_SIZE instead of 512 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jes Sorensen Clean up block.c and use BDRV_SECTOR_SIZE rather than hard coded numbers (512) when referring to sector size throughout the code. Signed-off-by: Jes Sorensen --- block.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index a094454..88806fb 100644 --- a/block.c +++ b/block.c @@ -683,7 +683,7 @@ int bdrv_commit(BlockDriverState *bs) int64_t i, total_sectors; int n, j, ro, open_flags; int ret = 0, rw_ret = 0; - unsigned char sector[512]; + unsigned char sector[BDRV_SECTOR_SIZE]; char filename[1024]; BlockDriverState *bs_rw, *bs_ro; @@ -823,7 +823,8 @@ static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset, static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { - return bdrv_check_byte_request(bs, sector_num * 512, nb_sectors * 512); + return bdrv_check_byte_request(bs, sector_num * BDRV_SECTOR_SIZE, + nb_sectors * BDRV_SECTOR_SIZE); } /* return < 0 if error. See bdrv_write() for the return codes */ @@ -1058,7 +1059,7 @@ struct partition { static int guess_disk_lchs(BlockDriverState *bs, int *pcylinders, int *pheads, int *psectors) { - uint8_t buf[512]; + uint8_t buf[BDRV_SECTOR_SIZE]; int ret, i, heads, sectors, cylinders; struct partition *p; uint32_t nr_sects; @@ -1561,7 +1562,7 @@ static QObject* bdrv_info_stats_bs(BlockDriverState *bs) "} }", bs->rd_bytes, bs->wr_bytes, bs->rd_ops, bs->wr_ops, - bs->wr_highest_sector * 512); + bs->wr_highest_sector * (long)BDRV_SECTOR_SIZE); dict = qobject_to_qdict(res); if (*bs->device_name) { @@ -2265,7 +2266,7 @@ static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, async_ret = NOT_DONE; iov.iov_base = (void *)buf; - iov.iov_len = nb_sectors * 512; + iov.iov_len = nb_sectors * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&qiov, &iov, 1); acb = bdrv_aio_readv(bs, sector_num, &qiov, nb_sectors, bdrv_rw_em_cb, &async_ret); @@ -2296,7 +2297,7 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, async_ret = NOT_DONE; iov.iov_base = (void *)buf; - iov.iov_len = nb_sectors * 512; + iov.iov_len = nb_sectors * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&qiov, &iov, 1); acb = bdrv_aio_writev(bs, sector_num, &qiov, nb_sectors, bdrv_rw_em_cb, &async_ret);