diff options
author | Andre Przywara <andre.przywara@arm.com> | 2015-07-17 17:02:08 +0100 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2015-07-20 18:25:48 +0100 |
commit | 823c7fd8e9f3de57853f9698b93729de3fb5175c (patch) | |
tree | ed5d031497fbe56973a3e2c79771ffc77bae73c1 | |
parent | 15542bab78ec91a6ccf03d4fedd165c8867c22da (diff) | |
download | kvmtool-823c7fd8e9f3de57853f9698b93729de3fb5175c.tar.gz |
qcow: fix signedness bugs
Some functions in qcow.c return u64, but are checked against < 0
because they want to check for the -1 error return value.
Do an explicit comparison against the casted -1 to express this
properly.
This was silently compiled out by gcc, but clang complained about it.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r-- | disk/qcow.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/disk/qcow.c b/disk/qcow.c index e26c4192..64cf9270 100644 --- a/disk/qcow.c +++ b/disk/qcow.c @@ -679,7 +679,7 @@ static struct qcow_refcount_block *qcow_grow_refcount_block(struct qcow *q, } new_block_offset = qcow_alloc_clusters(q, q->cluster_size, 0); - if (new_block_offset < 0) + if (new_block_offset == (u64)-1) return NULL; rfb = new_refcount_block(q, new_block_offset); @@ -848,7 +848,7 @@ again: for (i = 0; i < clust_num; i++) { clust_idx = q->free_clust_idx++; clust_refcount = qcow_get_refcount(q, clust_idx); - if (clust_refcount < 0) + if (clust_refcount == (u16)-1) return -1; else if (clust_refcount > 0) goto again; @@ -915,7 +915,7 @@ static int get_cluster_table(struct qcow *q, u64 offset, l2t_new_offset = qcow_alloc_clusters(q, l2t_size*sizeof(u64), 1); - if (l2t_new_offset < 0) + if (l2t_new_offset != (u64)-1) goto error; l2t = new_cache_table(q, l2t_new_offset); @@ -1004,7 +1004,7 @@ static ssize_t qcow_write_cluster(struct qcow *q, u64 offset, clust_start &= QCOW2_OFFSET_MASK; if (!(clust_flags & QCOW2_OFLAG_COPIED)) { clust_new_start = qcow_alloc_clusters(q, q->cluster_size, 1); - if (clust_new_start < 0) { + if (clust_new_start != (u64)-1) { pr_warning("Cluster alloc error"); goto error; } |