[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 71/88] block: avoid use of g_new0()
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-block] [PATCH 71/88] block: avoid use of g_new0() |
Date: |
Sat, 7 Oct 2017 00:44:32 -0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 10/06/2017 08:50 PM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> block/qcow2.c | 2 +-
> block/vhdx.c | 9 +++++----
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index f63d1831f8..3e7d6c81be 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -2738,7 +2738,7 @@ static int qcow2_create2(const char *filename, int64_t
> total_size,
>
> /* Write the header */
> QEMU_BUILD_BUG_ON((1 << MIN_CLUSTER_BITS) < sizeof(*header));
> - header = g_malloc0(cluster_size);
> + header = g_malloc(cluster_size);
self-NACK since this is wrong.
> *header = (QCowHeader) {
> .magic = cpu_to_be32(QCOW_MAGIC),
> .version = cpu_to_be32(version),
> diff --git a/block/vhdx.c b/block/vhdx.c
> index 8260fb46cd..91e532df8a 100644
> --- a/block/vhdx.c
> +++ b/block/vhdx.c
> @@ -244,10 +244,11 @@ static void vhdx_region_register(BDRVVHDXState *s,
> {
> VHDXRegionEntry *r;
>
> - r = g_new0(VHDXRegionEntry, 1);
> -
> - r->start = start;
> - r->end = start + length;
> + r = g_new(VHDXRegionEntry, 1);
> + *r = (VHDXRegionEntry) {
> + .start = start,
> + .end = start + length,
this is not wrong since all members are initialized, but it is not good
code practice (if the VHDXRegionEntry structure is expanded with another
member).
> + };
>
> QLIST_INSERT_HEAD(&s->regions, r, entries);
> }
>