Skip to content

Commit bec4042

Browse files
Vladimir Sementsov-Ogievskiyebblake
authored andcommitted
block-backend: update blk_co_pwrite() and blk_co_pread() wrappers
Make bytes argument int64_t to be consistent with modern block-layer. Callers should be OK with it as type becomes wider. What is inside functions? - Conversion from int64_t to size_t. Still, we can't have a buffer larger than SIZE_MAX, therefore bytes should not be larger than SIZE_MAX as well. Add an assertion. - Passing to blk_co_pwritev() / blk_co_preadv() which already has int64_t bytes argument. Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> Message-Id: <[email protected]> Reviewed-by: Eric Blake <[email protected]> [eblake: spelling fix] Signed-off-by: Eric Blake <[email protected]>
1 parent 57768ec commit bec4042

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

include/sysemu/block-backend.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,24 @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset,
137137
BdrvRequestFlags flags);
138138

139139
static inline int coroutine_fn blk_co_pread(BlockBackend *blk, int64_t offset,
140-
unsigned int bytes, void *buf,
140+
int64_t bytes, void *buf,
141141
BdrvRequestFlags flags)
142142
{
143143
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
144144

145+
assert(bytes <= SIZE_MAX);
146+
145147
return blk_co_preadv(blk, offset, bytes, &qiov, flags);
146148
}
147149

148150
static inline int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t offset,
149-
unsigned int bytes, void *buf,
151+
int64_t bytes, void *buf,
150152
BdrvRequestFlags flags)
151153
{
152154
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
153155

156+
assert(bytes <= SIZE_MAX);
157+
154158
return blk_co_pwritev(blk, offset, bytes, &qiov, flags);
155159
}
156160

0 commit comments

Comments
 (0)