[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 13/22] spapr_pci: convert g_malloc() to g_new()
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 13/22] spapr_pci: convert g_malloc() to g_new() |
Date: |
Thu, 8 Nov 2018 23:16:37 +1100 |
From: Greg Kurz <address@hidden>
When allocating an array, it is a recommended coding practice to call
g_new(FooType, n) instead of g_malloc(n * sizeof(FooType)) because
it takes care to avoid overflow when calculating the size of the
allocated block and it returns FooType *, which allows the compiler
to perform type checking.
Signed-off-by: Greg Kurz <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr_pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 58afa46204..2374d55fc1 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1882,7 +1882,7 @@ static int spapr_pci_pre_save(void *opaque)
if (!sphb->msi_devs_num) {
return 0;
}
- sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));
+ sphb->msi_devs = g_new(spapr_pci_msi_mig, sphb->msi_devs_num);
g_hash_table_iter_init(&iter, sphb->msi);
for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) {
--
2.19.1
- [Qemu-ppc] [PULL 00/22] ppc-for-3.1 queue 20181108, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 02/22] ppc440_pcix: convert SysBus init method to a realize method, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 03/22] ppc4xx_pci: convert SysBus init method to a realize method, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 08/22] target/ppc: Introduce fp number classification, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 10/22] target/ppc: Split out float_invalid_op_mul, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 04/22] PPC: e500: convert SysBus init method to a realize method, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 11/22] target/ppc: Split out float_invalid_op_div, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 19/22] hw/ppc/ppc440_uc: Remove dead code in sdram_size(), David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 13/22] spapr_pci: convert g_malloc() to g_new(),
David Gibson <=
- [Qemu-ppc] [PULL 09/22] target/ppc: Split out float_invalid_op_addsub, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 20/22] This patch fixes processing of rfi instructions in icount mode., David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 05/22] hw/ppc/spapr_rng: Introduce CONFIG_SPAPR_RNG switch for spapr_rng.c, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 18/22] MAINTAINERS: PPC: Remove myself, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 22/22] ppc/spapr_caps: Add SPAPR_CAP_NESTED_KVM_HV, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 12/22] target/ppc: Split out float_invalid_cvt, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 06/22] target/ppc: Split up float_invalid_op_excp, David Gibson, 2018/11/08
- [Qemu-ppc] [PULL 01/22] target/ppc: add external PID support, David Gibson, 2018/11/08