* [Qemu-devel] [PATCH] vhdx: fix g_try_malloc0 thinko
@ 2014-11-12 10:59 Paolo Bonzini
2014-11-12 11:09 ` Fam Zheng
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2014-11-12 10:59 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, jcody, stefanha
Spotted while looking at Coverity reports (though not found by
Coverity itself).
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/qcow2-snapshot.c | 2 +-
block/vhdx.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index f52d7fd..27d3bc1 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -465,7 +465,7 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
BDRVQcowState *s = bs->opaque;
QCowSnapshot *sn;
int i, snapshot_index;
- int cur_l1_bytes, sn_l1_bytes;
+ size_t cur_l1_bytes, sn_l1_bytes;
int ret;
uint64_t *sn_l1_table = NULL;
diff --git a/block/vhdx.c b/block/vhdx.c
index 87c99fc..bd1e403 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -1593,7 +1593,7 @@ static int vhdx_create_bat(BlockDriverState *bs, BDRVVHDXState *s,
bdrv_has_zero_init(bs) == 0) {
/* for a fixed file, the default BAT entry is not zero */
s->bat = g_try_malloc0(length);
- if (length && s->bat != NULL) {
+ if (length && s->bat == NULL) {
ret = -ENOMEM;
goto exit;
}
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vhdx: fix g_try_malloc0 thinko
2014-11-12 10:59 [Qemu-devel] [PATCH] vhdx: fix g_try_malloc0 thinko Paolo Bonzini
@ 2014-11-12 11:09 ` Fam Zheng
2014-11-12 11:14 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Fam Zheng @ 2014-11-12 11:09 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kwolf, jcody, qemu-devel, stefanha
On Wed, 11/12 11:59, Paolo Bonzini wrote:
> Spotted while looking at Coverity reports (though not found by
> Coverity itself).
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> block/qcow2-snapshot.c | 2 +-
> block/vhdx.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
> index f52d7fd..27d3bc1 100644
> --- a/block/qcow2-snapshot.c
> +++ b/block/qcow2-snapshot.c
> @@ -465,7 +465,7 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
> BDRVQcowState *s = bs->opaque;
> QCowSnapshot *sn;
> int i, snapshot_index;
> - int cur_l1_bytes, sn_l1_bytes;
> + size_t cur_l1_bytes, sn_l1_bytes;
> int ret;
> uint64_t *sn_l1_table = NULL;
>
> diff --git a/block/vhdx.c b/block/vhdx.c
> index 87c99fc..bd1e403 100644
> --- a/block/vhdx.c
> +++ b/block/vhdx.c
> @@ -1593,7 +1593,7 @@ static int vhdx_create_bat(BlockDriverState *bs, BDRVVHDXState *s,
> bdrv_has_zero_init(bs) == 0) {
> /* for a fixed file, the default BAT entry is not zero */
> s->bat = g_try_malloc0(length);
> - if (length && s->bat != NULL) {
> + if (length && s->bat == NULL) {
> ret = -ENOMEM;
> goto exit;
> }
> --
> 2.1.0
>
>
There is already:
commit a011898d25b8a26a311d56dfe37e8d3a4374ec65
Author: Adelina Tuvenie <adelinatuvenie@gmail.com>
Date: Thu Sep 18 18:17:44 2014 +0300
block: allow creation of fixed vhdx images
Fam
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vhdx: fix g_try_malloc0 thinko
2014-11-12 11:09 ` Fam Zheng
@ 2014-11-12 11:14 ` Paolo Bonzini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2014-11-12 11:14 UTC (permalink / raw)
To: Fam Zheng; +Cc: kwolf, jcody, qemu-devel, stefanha
On 12/11/2014 12:09, Fam Zheng wrote:
> There is already:
>
> commit a011898d25b8a26a311d56dfe37e8d3a4374ec65
> Author: Adelina Tuvenie <adelinatuvenie@gmail.com>
> Date: Thu Sep 18 18:17:44 2014 +0300
>
> block: allow creation of fixed vhdx images
Oops, old checkout. Thanks,
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-12 11:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-12 10:59 [Qemu-devel] [PATCH] vhdx: fix g_try_malloc0 thinko Paolo Bonzini
2014-11-12 11:09 ` Fam Zheng
2014-11-12 11:14 ` Paolo Bonzini
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).