bulk: Access existing variables initialized to &S->F when available
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Mon, 29 Jan 2024 16:44:43 +0000 (17:44 +0100)
committerThomas Huth <thuth@redhat.com>
Tue, 12 Mar 2024 10:46:16 +0000 (11:46 +0100)
commitee1004bba6eadeddf988a29716dc28849c0211c8
tree6c7373918fe1ddf1db3973400105b99b84c4fdaf
parent46ff64a826bbd70e98484c8c7f4c3c1d83363f1d
bulk: Access existing variables initialized to &S->F when available

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@intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240129164514.73104-2-philmd@linaro.org>
Acked-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
[thuth: Dropped hunks that need a rebase, and fixed sizeof() in pmu_realize()]
Signed-off-by: Thomas Huth <thuth@redhat.com>
15 files changed:
hw/display/ati.c
hw/misc/macio/pmu.c
hw/misc/pvpanic-pci.c
hw/pci-bridge/cxl_root_port.c
hw/ppc/pnv.c
hw/virtio/vhost-user-scmi.c
hw/virtio/virtio-pci.c
hw/xen/xen_pt.c
migration/multifd-zlib.c
target/arm/cpu.c
target/arm/kvm.c
target/arm/machine.c
target/i386/hvf/x86hvf.c
target/m68k/helper.c
target/ppc/kvm.c