[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/15] block-backend: blk_check_byte_request(): int64_t bytes
From: |
Eric Blake |
Subject: |
[PULL 02/15] block-backend: blk_check_byte_request(): int64_t bytes |
Date: |
Fri, 15 Oct 2021 16:09:57 -0500 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Rename size and make it int64_t to correspond to modern block layer,
which always uses int64_t for offset and bytes (not in blk layer yet,
which is a task for following commits).
All callers pass int or unsigned int.
So, for bytes in [0, INT_MAX] nothing is changed, for negative bytes we
now fail on "bytes < 0" check instead of "bytes > INT_MAX" check.
Note, that blk_check_byte_request() still doesn't allow requests
exceeding INT_MAX.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20211006131718.214235-2-vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
block/block-backend.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index ba2b5ebb1008..2c62210687e7 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1161,11 +1161,11 @@ void blk_set_disable_request_queuing(BlockBackend *blk,
bool disable)
}
static int blk_check_byte_request(BlockBackend *blk, int64_t offset,
- size_t size)
+ int64_t bytes)
{
int64_t len;
- if (size > INT_MAX) {
+ if (bytes < 0 || bytes > INT_MAX) {
return -EIO;
}
@@ -1183,7 +1183,7 @@ static int blk_check_byte_request(BlockBackend *blk,
int64_t offset,
return len;
}
- if (offset > len || len - offset < size) {
+ if (offset > len || len - offset < bytes) {
return -EIO;
}
}
--
2.31.1
- [PULL 00/15] NBD patches through 2021-10-15, Eric Blake, 2021/10/15
- [PULL 05/15] block-backend: convert blk_co_pdiscard to int64_t bytes, Eric Blake, 2021/10/15
- [PULL 01/15] qcow2: Silence clang -m32 compiler warning, Eric Blake, 2021/10/15
- [PULL 04/15] block-backend: convert blk_co_pwritev_part to int64_t bytes, Eric Blake, 2021/10/15
- [PULL 02/15] block-backend: blk_check_byte_request(): int64_t bytes,
Eric Blake <=
- [PULL 06/15] block-backend: rename _do_ helper functions to _co_do_, Eric Blake, 2021/10/15
- [PULL 03/15] block-backend: make blk_co_preadv() 64bit, Eric Blake, 2021/10/15
- [PULL 08/15] block-backend: drop blk_prw, use block-coroutine-wrapper, Eric Blake, 2021/10/15
- [PULL 11/15] block-backend: convert blk_aio_ functions to int64_t bytes paramter, Eric Blake, 2021/10/15
- [PULL 09/15] block-backend: convert blk_foo wrappers to use int64_t bytes parameter, Eric Blake, 2021/10/15
- [PULL 10/15] block-backend: convert blk_co_copy_range to int64_t bytes, Eric Blake, 2021/10/15
- [PULL 07/15] block-coroutine-wrapper.py: support BlockBackend first argument, Eric Blake, 2021/10/15
- [PULL 12/15] block-backend: blk_pread, blk_pwrite: rename count parameter to bytes, Eric Blake, 2021/10/15
- [PULL 14/15] block-backend: fix blk_co_flush prototype to mention coroutine_fn, Eric Blake, 2021/10/15
- [PULL 15/15] block-backend: update blk_co_pwrite() and blk_co_pread() wrappers, Eric Blake, 2021/10/15