Skip to content
Snippets Groups Projects
Commit 705eab2c authored by Pekka Enberg's avatar Pekka Enberg
Browse files

virtio-blk: Clean up signedness casts


Switch to size_t type for ->bio_bcount in struct bio and clean up
virtio-blk signedness casts.

Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 1429e5c0
No related branches found
No related tags found
No related merge requests found
......@@ -257,12 +257,12 @@ int virtio_blk::make_virtio_request(struct bio* bio)
// need to break a contiguous buffers that > 4k into several physical page mapping
// even if the virtual space is contiguous.
long len = 0;
int offset = reinterpret_cast<long>(bio->bio_data) & 0xfff;
size_t len = 0;
auto offset = reinterpret_cast<size_t>(bio->bio_data) & 0xfff;
void *base = bio->bio_data;
while (len != bio->bio_bcount) {
long size = std::min(bio->bio_bcount - len, (long)mmu::page_size);
if (offset + size > (long)mmu::page_size)
auto size = std::min(bio->bio_bcount - len, mmu::page_size);
if (offset + size > mmu::page_size)
size = mmu::page_size - offset;
len += size;
queue->_sg_vec.push_back(vring::sg_node(mmu::virt_to_phys(base), size, (type == VIRTIO_BLK_T_OUT)? vring_desc::VRING_DESC_F_READ:vring_desc::VRING_DESC_F_WRITE));
......
......@@ -81,7 +81,7 @@ struct bio {
uint8_t bio_flags; /* General flags. */
struct device *bio_dev; /* Device to do I/O on. */
off_t bio_offset; /* Offset into file. */
long bio_bcount; /* Valid bytes in buffer. */
size_t bio_bcount; /* Valid bytes in buffer. */
void *bio_data; /* Memory, superblocks, indirect etc. */
int bio_error; /* Errno for BIO_ERROR. */
long bio_resid; /* Remaining I/O in bytes. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment