qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qcow2: Fix signedness bugs
@ 2010-02-02 14:20 Kevin Wolf
  2010-02-03 17:58 ` Markus Armbruster
  2010-02-10 18:32 ` Anthony Liguori
  0 siblings, 2 replies; 3+ messages in thread
From: Kevin Wolf @ 2010-02-02 14:20 UTC (permalink / raw)
  To: qemu-devel

Checking for return codes < 0 isn't really going to work with unsigned
types. Use signed types instead.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qcow2: Fix signedness bugs
  2010-02-02 14:20 [Qemu-devel] [PATCH] qcow2: Fix signedness bugs Kevin Wolf
@ 2010-02-03 17:58 ` Markus Armbruster
  2010-02-10 18:32 ` Anthony Liguori
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2010-02-03 17:58 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel

Kevin Wolf <kwolf@redhat.com> writes:

> Checking for return codes < 0 isn't really going to work with unsigned
> types. Use signed types instead.

Makes sense to me.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qcow2: Fix signedness bugs
  2010-02-02 14:20 [Qemu-devel] [PATCH] qcow2: Fix signedness bugs Kevin Wolf
  2010-02-03 17:58 ` Markus Armbruster
@ 2010-02-10 18:32 ` Anthony Liguori
  1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2010-02-10 18:32 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel

On 02/02/2010 08:20 AM, Kevin Wolf wrote:
> Checking for return codes<  0 isn't really going to work with unsigned
> types. Use signed types instead.
>
> Signed-off-by: Kevin Wolf<kwolf@redhat.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>   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);
>    

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-10 18:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-02 14:20 [Qemu-devel] [PATCH] qcow2: Fix signedness bugs Kevin Wolf
2010-02-03 17:58 ` Markus Armbruster
2010-02-10 18:32 ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).