[Top][All Lists]

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

Re: [PATCH 0/3] Use g_new() & friends where that makes obvious

From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 0/3] Use g_new() & friends where that makes obvious
Date: Mon, 14 Mar 2022 17:41:09 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1

On 14/3/22 17:01, Markus Armbruster wrote:
g_new(T, n) is neater than g_malloc(sizeof(T) * n).  It's also safer,
for two reasons.  One, it catches multiplication overflowing size_t.
Two, it returns T * rather than void *, which lets the compiler catch
more type errors.

This series only touches allocations with size arguments of the form
sizeof(T).  It's mechanical, except for a tiny fix in PATCH 2.

PATCH 1 adds the Coccinelle script.

PATCH 2 cleans up the virtio-9p subsystem, and fixes a harmless typing
error uncovered by the cleanup.

PATCH 3 cleans up everything else.  I started to split it up, but
splitting is a lot of decisions, and I just can't see the value.

For instance, MAINTAINERS tells me to split for subsystem "virtio",


But it also tells me to split for subsystem "Character devices",

     hw/char/parallel.c                       |  2 +-
     hw/char/riscv_htif.c                     |  2 +-
     hw/char/virtio-serial-bus.c              |  6 +-

and for subsystem "Network devices", patching


and for subsystem "virtio-gpu", patching


I guess I'd go with "virtio".  Six files down, 103 to go.  Thanks, but
no thanks.

Since the transformation is local to a function call, dropping is
completely safe.  We can deal with conflicts by dropping conflicting
hunks, with "git-pull -s recursive -X ours".  Or drop entire files
with conflicts.

If you want me to split off certain parts, please tell me exactly what
you want split off, and I'll gladly do the splitting.  I don't mind
the splitting part, I do mind the *thinking* part.

Markus Armbruster (3):
   scripts/coccinelle: New use-g_new-etc.cocci
   9pfs: Use g_new() & friends where that makes obvious sense
   Use g_new() & friends where that makes obvious sense

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

reply via email to

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