]> git.proxmox.com Git - mirror_qemu.git/commit - block/qcow2.c
qcow2: Fix Coverity warning when calculating the refcount cache size
authorAlberto Garcia <berto@igalia.com>
Mon, 28 May 2018 15:01:28 +0000 (17:01 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 29 May 2018 18:09:17 +0000 (20:09 +0200)
commit7af5eea9b34ffb7a9a9fc25ba71998a02b76e159
tree9501a0b5d3c2e3898b9d21ae93e72875415e65fc
parente609fa71e89c81fbe2670411be62da95dfb093e0
qcow2: Fix Coverity warning when calculating the refcount cache size

MIN_REFCOUNT_CACHE_SIZE is 4 and the cluster size is guaranteed to be
at most 2MB, so the minimum refcount cache size (in bytes) is always
going to fit in a 32-bit integer.

Coverity doesn't know that, and since we're storing the result in a
uint64_t (*refcount_cache_size) it thinks that we need the 64 bits and
that we probably want to do a 64-bit multiplication to prevent the
result from being truncated.

This is a false positive in this case, but it's a fair warning.
We could do a 64-bit multiplication to get rid of it, but since we
know that a 32-bit variable is enough to store this value let's simply
reuse min_refcount_cache, make it a normal int and stop doing casts.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2.c