qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jes.Sorensen@redhat.com
To: anthony@codemonkey.ws
Cc: Jes Sorensen <Jes.Sorensen@redhat.com>, qemu-devel@nongnu.org
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	[thread overview]
Message-ID: <1274970033-24093-3-git-send-email-Jes.Sorensen@redhat.com> (raw)
In-Reply-To: <1274970033-24093-1-git-send-email-Jes.Sorensen@redhat.com>

From: Jes Sorensen <Jes.Sorensen@redhat.com>

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 <Jes.Sorensen@redhat.com>
---
 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

  parent reply	other threads:[~2010-05-27 14:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27 14:20 [Qemu-devel] [PATCH 0/4] Cleanups for block code Jes.Sorensen
2010-05-27 14:20 ` [Qemu-devel] [PATCH 1/4] Cleanup: bdrv_open() no need to shift total_size just to shift back Jes.Sorensen
2010-05-27 14:20 ` Jes.Sorensen [this message]
2010-05-27 14:20 ` [Qemu-devel] [PATCH 3/4] Cleanup: raw-posix.c: Be more consistent using BDRV_SECTOR_SIZE instead of 512 Jes.Sorensen
2010-05-27 14:20 ` [Qemu-devel] [PATCH 4/4] Cleanup: virtio-blk.c: Be more consistent using BDRV_SECTOR_SIZE instead Jes.Sorensen
2010-05-28 13:48 ` [Qemu-devel] [PATCH 0/4] Cleanups for block code Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1274970033-24093-3-git-send-email-Jes.Sorensen@redhat.com \
    --to=jes.sorensen@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).