[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/27] Cleanup: Be consistent and use BDRV_SECTOR_SI
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 02/27] Cleanup: Be consistent and use BDRV_SECTOR_SIZE instead of 512 |
Date: |
Fri, 4 Jun 2010 18:32:50 +0200 |
From: Jes Sorensen <address@hidden>
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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c
index 8385b4f..9c43332 100644
--- a/block.c
+++ b/block.c
@@ -684,7 +684,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;
@@ -824,7 +824,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 */
@@ -1059,7 +1060,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;
@@ -1535,7 +1536,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) {
@@ -2197,7 +2198,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);
@@ -2228,7 +2229,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);
--
1.6.6.1
- [Qemu-devel] [PULL 00/27] Block patches, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 15/27] qdev: Don't leak string property value on hot unplug, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 16/27] ide: Turn drive serial into a qdev property ide-drive.serial, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 06/27] blockdev: Belatedly remove MAX_DRIVES, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 07/27] blockdev: Belatedly remove driveopts, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 01/27] Cleanup: bdrv_open() no need to shift total_size just to shift back., Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 11/27] ide: Split ide_init1() off ide_init2(), Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 02/27] Cleanup: Be consistent and use BDRV_SECTOR_SIZE instead of 512,
Kevin Wolf <=
- [Qemu-devel] [PATCH 04/27] Cleanup: virtio-blk.c: Be more consistent using BDRV_SECTOR_SIZE instead, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 05/27] qemu-io: Fix error messages, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 08/27] usb: Remove unused usb_device_add() parameter is_hotplug, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 14/27] qdev: New qdev_prop_set_string(), Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 13/27] ide: Split non-qdev code off ide_init2(), Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 10/27] ide: Remove redundant IDEState member conf, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 12/27] ide: Change ide_init_drive() to require valid dinfo argument, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 03/27] Cleanup: raw-posix.c: Be more consistent using BDRV_SECTOR_SIZE instead of 512, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 09/27] ide: Remove useless IDEDeviceInfo members unit, drive, Kevin Wolf, 2010/06/04
- [Qemu-devel] [PATCH 17/27] ide: Fix info qtree for ide-drive.ver, Kevin Wolf, 2010/06/04