]> git.proxmox.com Git - mirror_qemu.git/commit
Use g_new() & friends where that makes obvious sense
authorMarkus Armbruster <armbru@redhat.com>
Tue, 15 Mar 2022 14:41:56 +0000 (15:41 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Mon, 21 Mar 2022 14:44:44 +0000 (15:44 +0100)
commitb21e2380376c470900fcadf47507f4d5ade75e85
tree7fd41d348f85d6ef66d6f10ca4df241ba0e74f83
parent1366244ab6d0c83bf0f90270e5bb608651a3cc8f
Use g_new() & friends where that makes obvious sense

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 commit only touches allocations with size arguments of the form
sizeof(T).

Patch created mechanically with:

    $ spatch --in-place --sp-file scripts/coccinelle/use-g_new-etc.cocci \
     --macro-file scripts/cocci-macro-file.h FILES...

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20220315144156.1595462-4-armbru@redhat.com>
Reviewed-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
102 files changed:
accel/kvm/kvm-all.c
accel/tcg/tcg-accel-ops-mttcg.c
accel/tcg/tcg-accel-ops-rr.c
audio/audio.c
audio/audio_legacy.c
audio/dsoundaudio.c
audio/jackaudio.c
audio/paaudio.c
backends/cryptodev.c
contrib/vhost-user-gpu/vhost-user-gpu.c
cpus-common.c
dump/dump.c
hw/acpi/hmat.c
hw/audio/intel-hda.c
hw/char/parallel.c
hw/char/riscv_htif.c
hw/char/virtio-serial-bus.c
hw/core/irq.c
hw/core/reset.c
hw/display/pxa2xx_lcd.c
hw/display/tc6393xb.c
hw/display/virtio-gpu.c
hw/display/xenfb.c
hw/dma/rc4030.c
hw/i2c/core.c
hw/i2c/i2c_mux_pca954x.c
hw/i386/amd_iommu.c
hw/i386/intel_iommu.c
hw/i386/xen/xen-hvm.c
hw/i386/xen/xen-mapcache.c
hw/input/lasips2.c
hw/input/pckbd.c
hw/input/ps2.c
hw/input/pxa2xx_keypad.c
hw/input/tsc2005.c
hw/intc/riscv_aclint.c
hw/intc/xics.c
hw/m68k/virt.c
hw/mips/mipssim.c
hw/misc/applesmc.c
hw/misc/imx6_src.c
hw/misc/ivshmem.c
hw/net/virtio-net.c
hw/nvme/ns.c
hw/pci-host/pnv_phb3.c
hw/pci-host/pnv_phb4.c
hw/pci/pcie_sriov.c
hw/ppc/e500.c
hw/ppc/ppc.c
hw/ppc/ppc405_boards.c
hw/ppc/ppc405_uc.c
hw/ppc/ppc4xx_devs.c
hw/ppc/ppc_booke.c
hw/ppc/spapr.c
hw/ppc/spapr_events.c
hw/ppc/spapr_hcall.c
hw/ppc/spapr_numa.c
hw/rdma/vmw/pvrdma_dev_ring.c
hw/rdma/vmw/pvrdma_qp_ops.c
hw/sh4/r2d.c
hw/sh4/sh7750.c
hw/sparc/leon3.c
hw/sparc64/sparc64.c
hw/timer/arm_timer.c
hw/timer/slavio_timer.c
hw/vfio/pci.c
hw/vfio/platform.c
hw/virtio/virtio-crypto.c
hw/virtio/virtio-iommu.c
hw/virtio/virtio.c
hw/xtensa/xtfpga.c
include/qemu/timer.h
linux-user/syscall.c
migration/dirtyrate.c
migration/multifd-zlib.c
migration/ram.c
monitor/misc.c
monitor/qmp-cmds.c
qga/commands-win32.c
qga/commands.c
qom/qom-qmp-cmds.c
replay/replay-char.c
replay/replay-events.c
softmmu/bootdevice.c
softmmu/dma-helpers.c
softmmu/memory_mapping.c
target/i386/cpu-sysemu.c
target/i386/hax/hax-accel-ops.c
target/i386/nvmm/nvmm-accel-ops.c
target/i386/whpx/whpx-accel-ops.c
target/i386/whpx/whpx-all.c
target/s390x/cpu-sysemu.c
tests/unit/test-hbitmap.c
tests/unit/test-qmp-cmds.c
tests/unit/test-qobject-output-visitor.c
tests/unit/test-vmstate.c
ui/vnc-enc-tight.c
util/envlist.c
util/hbitmap.c
util/main-loop.c
util/qemu-timer.c
util/vfio-helpers.c