[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 25/32] qemu-io: Use correct range limitations
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 25/32] qemu-io: Use correct range limitations |
Date: |
Fri, 8 Jul 2016 19:21:37 +0200 |
From: Max Reitz <address@hidden>
create_iovec() has a comment lamenting the lack of SIZE_T_MAX. Since
there actually is a SIZE_MAX, use it.
Two places use INT_MAX for checking the upper bound of a sector count
that is used as an argument for a blk_*() function (blk_discard() and
blk_write_compressed(), respectively). BDRV_REQUEST_MAX_SECTORS should
be used instead.
And finally, do_co_pwrite_zeroes() used to similarly check that the
sector count does not exceed INT_MAX. However, this function is now
backed by blk_co_pwrite_zeroes() which takes bytes as an argument
instead of sectors. Therefore, it should be the byte count that does not
exceed INT_MAX, not the sector count.
Signed-off-by: Max Reitz <address@hidden>
Message-id: address@hidden
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
qemu-io-cmds.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 40fe2eb..0fcf7c1 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -389,9 +389,8 @@ create_iovec(BlockBackend *blk, QEMUIOVector *qiov, char
**argv, int nr_iov,
goto fail;
}
- /* should be SIZE_T_MAX, but that doesn't exist */
- if (len > INT_MAX) {
- printf("Argument '%s' exceeds maximum size %d\n", arg, INT_MAX);
+ if (len > SIZE_MAX) {
+ printf("Argument '%s' exceeds maximum size %zu\n", arg, SIZE_MAX);
goto fail;
}
@@ -479,7 +478,7 @@ static int do_co_pwrite_zeroes(BlockBackend *blk, int64_t
offset,
.done = false,
};
- if (count >> BDRV_SECTOR_BITS > INT_MAX) {
+ if (count > INT_MAX) {
return -ERANGE;
}
@@ -500,7 +499,7 @@ static int do_write_compressed(BlockBackend *blk, char
*buf, int64_t offset,
{
int ret;
- if (count >> 9 > INT_MAX) {
+ if (count >> 9 > BDRV_REQUEST_MAX_SECTORS) {
return -ERANGE;
}
@@ -1688,9 +1687,9 @@ static int discard_f(BlockBackend *blk, int argc, char
**argv)
if (count < 0) {
print_cvtnum_err(count, argv[optind]);
return 0;
- } else if (count >> BDRV_SECTOR_BITS > INT_MAX) {
+ } else if (count >> BDRV_SECTOR_BITS > BDRV_REQUEST_MAX_SECTORS) {
printf("length cannot exceed %"PRIu64", given %s\n",
- (uint64_t)INT_MAX << BDRV_SECTOR_BITS,
+ (uint64_t)BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS,
argv[optind]);
return 0;
}
--
1.8.3.1
- Re: [Qemu-block] [PULL 19/32] commit: Fix use of error handling policy, (continued)
[Qemu-block] [PULL 16/32] coroutine: move entry argument to qemu_coroutine_create, Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 20/32] block/qdev: Allow configuring rerror/werror with qdev properties, Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 23/32] qemu-img: Use strerror() for generic resize error, Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 22/32] block: Remove BB options from blockdev-add, Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 21/32] qemu-iotests: Test setting WCE with qdev, Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 25/32] qemu-io: Use correct range limitations,
Kevin Wolf <=
[Qemu-block] [PULL 27/32] Improve block job rate limiting for small bandwidth values, Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 24/32] qcow2: Avoid making the L1 table too big, Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 26/32] qcow2: Fix qcow2_get_cluster_offset(), Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 28/32] vmdk: fix metadata write regression, Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 30/32] qemu-iotests: Test naming of throttling groups, Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 29/32] blockdev: Fix regression with the default naming of throttling groups, Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 31/32] hmp: use snapshot name to determine whether a snapshot is 'fully available', Kevin Wolf, 2016/07/08
[Qemu-block] [PULL 32/32] hmp: show all of snapshot info on every block dev in output of 'info snapshots', Kevin Wolf, 2016/07/08
Re: [Qemu-block] [Qemu-devel] [PULL 00/32] Block layer patches, Peter Maydell, 2016/07/11