[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 02/88] cocci: add more g_new() transformations
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 02/88] cocci: add more g_new() transformations |
Date: |
Mon, 09 Oct 2017 09:28:48 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
The commit message should explain the additional transformations briefly
and informally. In particular, why they're a good idea. Same for PATCH
3-5.
Philippe Mathieu-Daudé <address@hidden> writes:
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> scripts/coccinelle/g_new.cocci | 73
> ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 73 insertions(+)
>
> diff --git a/scripts/coccinelle/g_new.cocci b/scripts/coccinelle/g_new.cocci
> index 1e57685a6b..c767325a21 100644
> --- a/scripts/coccinelle/g_new.cocci
> +++ b/scripts/coccinelle/g_new.cocci
> @@ -80,6 +80,49 @@ expression p, n;
> -g_try_realloc(p, sizeof(T) * (n))
> +g_try_renew(T, p, n)
>
> +@@
> +type T;
> +expression n;
> +@@
> +(
> +-g_malloc_n(n, sizeof(T))
> ++g_new(T, n)
> +|
> +-g_malloc0_n(n, sizeof(T))
> ++g_new0(T, n)
> +|
> +-g_try_malloc_n(n, sizeof(T))
> ++g_try_new(T, n)
> +|
> +-g_try_malloc0_n(n, sizeof(T))
> ++g_try_new0(T, n)
> +)
> +
> +@@
> +type T;
> +identifier m;
> +@@
> +T *m;
> +...
> +(
> +-m = g_malloc(sizeof(*m));
> ++m = g_new(T, 1);
> +|
> +-m = g_malloc0(sizeof(*m));
> ++m = g_new0(T, 1);
> +|
> +-m = g_try_malloc(sizeof(*m));
> ++m = g_try_new(T, 1);
> +|
> +-m = g_try_malloc0(sizeof(*m));
> ++m = g_try_new0(T, 1);
> +)
> +
> +////////////////////////////////////////
Please scratch this line. Overly elaborate comment decoration.
> +//
> +// last transformations: cleanups
> +//
> +
> // drop superfluous cast
> @@
> type T;
> @@ -99,3 +142,33 @@ expression p, n;
> @@
> -(T *)g_renew(T, p, n)
> +g_renew(T, p, n)
> +@@
> +type T;
> +expression n;
> +@@
> +(
> +-(T *)g_try_new(T, n)
> ++g_try_new(T, n)
> +|
> +-(T *)g_try_new0(T, n)
> ++g_try_new0(T, n)
> +)
> +
> +// drop superfluous parenthesis
> +@@
> +type T;
> +expression c;
> +@@
> +(
> +-g_new(T, (c))
> ++g_new(T, c)
> +|
> +-g_try_new(T, (c))
> ++g_try_new(T, c)
> +|
> +-g_new0(T, (c))
> ++g_new0(T, c)
> +|
> +-g_try_new0(T, (c))
> ++g_try_new0(T, c)
> +)
- [Qemu-devel] [PATCH 00/88] use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-devel] [PATCH 01/88] cocci: script to use g_new() & friends, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-devel] [PATCH 02/88] cocci: add more g_new() transformations, Philippe Mathieu-Daudé, 2017/10/06
- Re: [Qemu-devel] [PATCH 02/88] cocci: add more g_new() transformations,
Markus Armbruster <=
- [Qemu-devel] [PATCH 03/88] cocci: extract typeof() from g_new(), Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-devel] [PATCH 04/88] cocci: avoid use of g_new0(), Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-devel] [PATCH 05/88] cocci: use g_strfreev(), Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-devel] [PATCH 06/88] ARM: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-devel] [PATCH 07/88] Audio: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-devel] [PATCH 08/88] BT: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-devel] [PATCH 09/88] Bootdevice: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-devel] [PATCH 10/88] Character devices: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-devel] [PATCH 11/88] Cryptodev Backends: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06