From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NcJda-0000FW-Jh for qemu-devel@nongnu.org; Tue, 02 Feb 2010 09:21:54 -0500 Received: from [199.232.76.173] (port=50171 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcJdZ-0000FO-5J for qemu-devel@nongnu.org; Tue, 02 Feb 2010 09:21:53 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NcJdX-0005cB-6J for qemu-devel@nongnu.org; Tue, 02 Feb 2010 09:21:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55872) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NcJdW-0005bS-Gk for qemu-devel@nongnu.org; Tue, 02 Feb 2010 09:21:51 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o12ELmHF002640 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 2 Feb 2010 09:21:48 -0500 Received: from localhost.localdomain (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o12ELlLm017990 for ; Tue, 2 Feb 2010 09:21:47 -0500 From: Kevin Wolf Date: Tue, 2 Feb 2010 15:20:57 +0100 Message-Id: <1265120457-25143-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] qcow2: Fix signedness bugs List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Checking for return codes < 0 isn't really going to work with unsigned types. Use signed types instead. Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 12 ++++++------ block/qcow2.h | 6 ++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 4e30d16..3501a94 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -219,7 +219,8 @@ static uint64_t *l2_allocate(BlockDriverState *bs, int l1_index) BDRVQcowState *s = bs->opaque; int min_index; uint64_t old_l2_offset; - uint64_t *l2_table, l2_offset; + uint64_t *l2_table; + int64_t l2_offset; old_l2_offset = s->l1_table[l1_index]; @@ -560,7 +561,8 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, { BDRVQcowState *s = bs->opaque; int l2_index, ret; - uint64_t l2_offset, *l2_table, cluster_offset; + uint64_t l2_offset, *l2_table; + int64_t cluster_offset; int nb_csectors; ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index); @@ -704,10 +706,8 @@ err: * * Return 0 on success and -errno in error cases */ -uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs, - uint64_t offset, - int n_start, int n_end, - int *num, QCowL2Meta *m) +int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, + int n_start, int n_end, int *num, QCowL2Meta *m) { BDRVQcowState *s = bs->opaque; int l2_index, ret; diff --git a/block/qcow2.h b/block/qcow2.h index d9ea6ab..de9397a 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -192,10 +192,8 @@ void qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num, uint64_t qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num); -uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs, - uint64_t offset, - int n_start, int n_end, - int *num, QCowL2Meta *m); +int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, + int n_start, int n_end, int *num, QCowL2Meta *m); uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offset, int compressed_size); -- 1.6.5.2