[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/4] Cleanup: Be consistent and use BDRV_SECTOR_SIZE
From: |
Jes . Sorensen |
Subject: |
[Qemu-devel] [PATCH 2/4] Cleanup: Be consistent and use BDRV_SECTOR_SIZE instead of 512 |
Date: |
Thu, 27 May 2010 16:20:31 +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>
---
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);
--
1.6.5.2