qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [PATCH 34/88] qapi: use g_new() family of functions


From: Eric Blake
Subject: Re: [Qemu-trivial] [PATCH 34/88] qapi: use g_new() family of functions
Date: Mon, 9 Oct 2017 12:59:31 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 10/06/2017 06:49 PM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
>  qapi/opts-visitor.c           | 2 +-
>  qapi/qapi-clone-visitor.c     | 2 +-
>  qapi/qapi-dealloc-visitor.c   | 2 +-
>  qapi/qobject-output-visitor.c | 2 +-
>  qapi/string-input-visitor.c   | 2 +-
>  qapi/string-output-visitor.c  | 2 +-
>  6 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
> index 324b197495..34ac49f3c2 100644
> --- a/qapi/opts-visitor.c
> +++ b/qapi/opts-visitor.c
> @@ -539,7 +539,7 @@ opts_visitor_new(const QemuOpts *opts)
>      OptsVisitor *ov;
>  
>      assert(opts);
> -    ov = g_malloc0(sizeof *ov);
> +    ov = g_new0(OptsVisitor, 1);

Transformations like this are harder to justify - you have more typing
rather than less, and no change in the amount of type-safety.

If we really want to convert LHS = g_malloc0(sizeof(*LHS)), we probably
ought to have a stronger justification (consistency might be such an
argument, if the entire series is applied and HACKING is updated to
mention our new preferred style, and where the checked-in Coccinelle
script can be easily re-run in the future to catch regressions).

Converting LHS = g_malloc0(sizeof(type)) is a no-brainer, because it
DOES add type-safety, and often results in less typing.  But I haven't
looked at your entire series to see which patches fall in the no-brainer
category vs. the weakly-argued consistency category.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]