The uint16_t type is too small for MAX_BLOCK_SIZE (2 MiB). The int64_t type is widely used in QEMU as a type for disk offsets and sizes, so it's an appropriate type to use here. It will work for all callers.
Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> --- util/block-helpers.h | 2 +- util/block-helpers.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/util/block-helpers.h b/util/block-helpers.h index 46975ca7af..ec6421560c 100644 --- a/util/block-helpers.h +++ b/util/block-helpers.h @@ -13,7 +13,7 @@ #define MAX_BLOCK_SIZE (2 * MiB) #define MAX_BLOCK_SIZE_STR "2 MiB" -void check_logical_block_size(const char *id, const char *name, uint16_t value, +void check_logical_block_size(const char *id, const char *name, int64_t value, Error **errp); #endif /* BLOCK_HELPERS_H */ diff --git a/util/block-helpers.c b/util/block-helpers.c index 089fe3401d..9e68954c46 100644 --- a/util/block-helpers.c +++ b/util/block-helpers.c @@ -22,7 +22,7 @@ * * Moved from hw/core/qdev-properties.c:set_blocksize() */ -void check_logical_block_size(const char *id, const char *name, uint16_t value, +void check_logical_block_size(const char *id, const char *name, int64_t value, Error **errp) { /* value of 0 means "unset" */ @@ -37,7 +37,7 @@ void check_logical_block_size(const char *id, const char *name, uint16_t value, error_setg(errp, "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2", - id, name, (int64_t)value); + id, name, value); return; } } -- 2.26.2