[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 0/3] Use g_new() & friends where that makes obvious
- To: Markus Armbruster <armbru@xxxxxxxxxx>, qemu-devel@xxxxxxxxxx
- From: Philippe Mathieu-Daudé <philippe.mathieu.daude@xxxxxxxxx>
- Date: Mon, 14 Mar 2022 17:41:09 +0100
- Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>, Richard Henderson <richard.henderson@xxxxxxxxxx>, Gerd Hoffmann <kraxel@xxxxxxxxxx>, Christian Schoenebeck <qemu_oss@xxxxxxxxxxxxx>, "Gonglei (Arei)" <arei.gonglei@xxxxxxxxxx>, Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Igor Mammedov <imammedo@xxxxxxxxxx>, Ani Sinha <ani@xxxxxxxxxxx>, Laurent Vivier <lvivier@xxxxxxxxxx>, Amit Shah <amit@xxxxxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Hervé Poussineau <hpoussin@xxxxxxxxxxx>, Aleksandar Rikalo <aleksandar.rikalo@xxxxxxxxxx>, Corey Minyard <cminyard@xxxxxxxxxx>, Patrick Venture <venture@xxxxxxxxxx>, Eduardo Habkost <eduardo@xxxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, Peter Xu <peterx@xxxxxxxxxx>, Jason Wang <jasowang@xxxxxxxxxx>, Cédric Le Goater <clg@xxxxxxxx>, Daniel Henrique Barboza <danielhb413@xxxxxxxxx>, David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>, Greg Kurz <groug@xxxxxxxx>, Philippe Mathieu-Daudé <f4bug@xxxxxxxxx>, Jean-Christophe Dubois <jcd@xxxxxxxxxxxxxxx>, Keith Busch <kbusch@xxxxxxxxxx>, Klaus Jensen <its@xxxxxxxxxxxxx>, Yuval Shaia <yuval.shaia.ml@xxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, Magnus Damm <magnus.damm@xxxxxxxxx>, Fabien Chouteau <chouteau@xxxxxxxxxxx>, KONRAD Frederic <frederic.konrad@xxxxxxxxxxx>, Mark Cave-Ayland <mark.cave-ayland@xxxxxxxxxxxx>, Artyom Tarasenko <atar4qemu@xxxxxxxxx>, Alex Williamson <alex.williamson@xxxxxxxxxx>, Eric Auger <eric.auger@xxxxxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, Juan Quintela <quintela@xxxxxxxxxx>, "Dr. David Alan Gilbert" <dgilbert@xxxxxxxxxx>, Konstantin Kostiuk <kkostiuk@xxxxxxxxxx>, Michael Roth <michael.roth@xxxxxxx>, Daniel P. Berrangé <berrange@xxxxxxxxxx>, Pavel Dovgalyuk <pavel.dovgaluk@xxxxxxxxx>, Alex Bennée <alex.bennee@xxxxxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>, Wenchao Wang <wenchao.wang@xxxxxxxxx>, Colin Xu <colin.xu@xxxxxxxxx>, Kamil Rytarowski <kamil@xxxxxxxxxx>, Reinoud Zandijk <reinoud@xxxxxxxxxx>, Sunil Muthuswamy <sunilmut@xxxxxxxxxxxxx>, Cornelia Huck <cohuck@xxxxxxxxxx>, Thomas Huth <thuth@xxxxxxxxxx>, Eric Blake <eblake@xxxxxxxxxx>, Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx>, John Snow <jsnow@xxxxxxxxxx>, kvm@xxxxxxxxxxxxxxx, qemu-arm@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, qemu-ppc@xxxxxxxxxx, qemu-block@xxxxxxxxxx, haxm-team@xxxxxxxxx, qemu-s390x@xxxxxxxxxx
- Delivery-date: Tue, 15 Mar 2022 05:11:14 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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",
patching
hw/char/virtio-serial-bus.c
hw/display/virtio-gpu.c
hw/net/virtio-net.c
hw/virtio/virtio-crypto.c
hw/virtio/virtio-iommu.c
hw/virtio/virtio.c
But it also tells me to split for subsystem "Character devices",
patching
hw/char/parallel.c | 2 +-
hw/char/riscv_htif.c | 2 +-
hw/char/virtio-serial-bus.c | 6 +-
and for subsystem "Network devices", patching
hw/net/virtio-net.c
and for subsystem "virtio-gpu", patching
hw/display/virtio-gpu.c
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
Series:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@xxxxxxxxx>
|