[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 01/29] bulk: Access existing variables initialized to &S->F when available
- To: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
- From: BALATON Zoltan <balaton@xxxxxxxxxx>
- Date: Mon, 29 Jan 2024 20:46:41 +0100 (CET)
- Cc: qemu-devel@xxxxxxxxxx, qemu-riscv@xxxxxxxxxx, qemu-s390x@xxxxxxxxxx, Paolo Bonzini <pbonzini@xxxxxxxxxx>, kvm@xxxxxxxxxxxxxxx, qemu-ppc@xxxxxxxxxx, qemu-arm@xxxxxxxxxx, Richard Henderson <richard.henderson@xxxxxxxxxx>, Zhao Liu <zhao1.liu@xxxxxxxxx>, Mark Cave-Ayland <mark.cave-ayland@xxxxxxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, Cédric Le Goater <clg@xxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Frédéric Barrat <fbarrat@xxxxxxxxxxxxx>, Alex Bennée <alex.bennee@xxxxxxxxxx>, Viresh Kumar <viresh.kumar@xxxxxxxxxx>, mzamazal@xxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Peter Xu <peterx@xxxxxxxxxx>, Fabiano Rosas <farosas@xxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, Cameron Esfahani <dirty@xxxxxxxxx>, Roman Bolshakov <rbolshakov@xxxxxxx>, Laurent Vivier <laurent@xxxxxxxxx>, Daniel Henrique Barboza <danielhb413@xxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Bin Meng <bin.meng@xxxxxxxxxxxxx>, Weiwei Li <liwei1518@xxxxxxxxx>, Liu Zhiwei <zhiwei_liu@xxxxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Mon, 29 Jan 2024 19:47:04 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Mon, 29 Jan 2024, Philippe Mathieu-Daudé wrote:
When a variable is initialized to &struct->field, use it
in place. Rationale: while this makes the code more concise,
this also helps static analyzers.
Mechanical change using the following Coccinelle spatch script:
@@
type S, F;
identifier s, m, v;
@@
S *s;
...
F *v = &s->m;
<+...
- &s->m
+ v
...+>
Inspired-by: Zhao Liu <zhao1.liu@xxxxxxxxx>
Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
---
hw/display/ati.c | 2 +-
hw/misc/macio/pmu.c | 2 +-
hw/misc/pvpanic-pci.c | 2 +-
hw/pci-bridge/cxl_root_port.c | 2 +-
hw/ppc/pnv.c | 20 ++++++++++----------
hw/virtio/vhost-user-gpio.c | 8 ++++----
hw/virtio/vhost-user-scmi.c | 6 +++---
hw/virtio/virtio-pci.c | 2 +-
hw/xen/xen_pt.c | 6 +++---
migration/multifd-zlib.c | 2 +-
target/arm/cpu.c | 4 ++--
target/arm/kvm.c | 2 +-
target/arm/machine.c | 6 +++---
target/i386/hvf/x86hvf.c | 2 +-
target/m68k/helper.c | 2 +-
target/ppc/kvm.c | 8 ++++----
target/riscv/cpu_helper.c | 2 +-
17 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/hw/display/ati.c b/hw/display/ati.c
index 569b8f6165..8d2501bd82 100644
--- a/hw/display/ati.c
+++ b/hw/display/ati.c
@@ -991,7 +991,7 @@ static void ati_vga_realize(PCIDevice *dev, Error **errp)
}
vga_init(vga, OBJECT(s), pci_address_space(dev),
pci_address_space_io(dev), true);
- vga->con = graphic_console_init(DEVICE(s), 0, s->vga.hw_ops, &s->vga);
+ vga->con = graphic_console_init(DEVICE(s), 0, s->vga.hw_ops, vga);
if (s->cursor_guest_mode) {
vga->cursor_invalidate = ati_cursor_invalidate;
vga->cursor_draw_line = ati_cursor_draw_line;
diff --git a/hw/misc/macio/pmu.c b/hw/misc/macio/pmu.c
index e9a90da88f..7fe1c4e517 100644
--- a/hw/misc/macio/pmu.c
+++ b/hw/misc/macio/pmu.c
@@ -737,7 +737,7 @@ static void pmu_realize(DeviceState *dev, Error **errp)
timer_mod(s->one_sec_timer, s->one_sec_target);
if (s->has_adb) {
- qbus_init(&s->adb_bus, sizeof(s->adb_bus), TYPE_ADB_BUS,
+ qbus_init(adb_bus, sizeof(s->adb_bus), TYPE_ADB_BUS,
Probably should change to use sizeof(*adb_bus) too. Although the next line
is the only place the adb_bus local is used so maybe can drop the local
and chnage next line to use &s->adb_bus instead.
Regards,
BALATON Zoltan
dev, "adb.0");
adb_register_autopoll_callback(adb_bus, pmu_adb_poll, s);
}
|