summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorDoug Hogan <doug@cvs.openbsd.org>2014-12-09 06:58:30 +0000
committerDoug Hogan <doug@cvs.openbsd.org>2014-12-09 06:58:30 +0000
commitad90d9845d96f21749e3776b0296938c6d60ca9a (patch)
treeca999709d208d683272d9911f2706d59a203748f /sys/arch/amd64
parent7ac588b8eb1d276029001886214facee144b2fc5 (diff)
Replace some malloc(n*size,...) calls with mallocarray().
ok tedu@ deraadt@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/amd64/amd64_mem.c4
-rw-r--r--sys/arch/amd64/amd64/est.c6
-rw-r--r--sys/arch/amd64/amd64/ioapic.c4
-rw-r--r--sys/arch/amd64/amd64/mpbios.c6
-rw-r--r--sys/arch/amd64/amd64/via.c4
5 files changed, 12 insertions, 12 deletions
diff --git a/sys/arch/amd64/amd64/amd64_mem.c b/sys/arch/amd64/amd64/amd64_mem.c
index ce0fd6d7727..c84dad299e5 100644
--- a/sys/arch/amd64/amd64/amd64_mem.c
+++ b/sys/arch/amd64/amd64/amd64_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: amd64_mem.c,v 1.8 2014/07/13 12:11:01 jasper Exp $ */
+/* $OpenBSD: amd64_mem.c,v 1.9 2014/12/09 06:58:28 doug Exp $ */
/*
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
@@ -551,7 +551,7 @@ mrinit(struct mem_range_softc *sc)
printf("\n");
- sc->mr_desc = malloc(nmdesc * sizeof(struct mem_range_desc),
+ sc->mr_desc = mallocarray(nmdesc, sizeof(struct mem_range_desc),
M_MEMDESC, M_WAITOK|M_ZERO);
sc->mr_ndesc = nmdesc;
diff --git a/sys/arch/amd64/amd64/est.c b/sys/arch/amd64/amd64/est.c
index cea7696e189..944f75449ac 100644
--- a/sys/arch/amd64/amd64/est.c
+++ b/sys/arch/amd64/amd64/est.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: est.c,v 1.34 2014/09/14 14:17:23 jsg Exp $ */
+/* $OpenBSD: est.c,v 1.35 2014/12/09 06:58:28 doug Exp $ */
/*
* Copyright (c) 2003 Michael Eriksson.
* All rights reserved.
@@ -238,7 +238,7 @@ est_acpi_init()
== NULL)
goto nolist;
- if ((acpilist->table = malloc(sizeof(struct est_op) * nstates,
+ if ((acpilist->table = mallocarray(nstates, sizeof(struct est_op),
M_DEVBUF, M_NOWAIT)) == NULL)
goto notable;
@@ -278,7 +278,7 @@ est_acpi_pss_changed(struct acpicpu_pss *pss, int npss)
return;
}
- if ((acpilist->table = malloc(sizeof(struct est_op) * npss,
+ if ((acpilist->table = mallocarray(npss, sizeof(struct est_op),
M_DEVBUF, M_NOWAIT)) == NULL) {
printf("est_acpi_pss_changed: cannot allocate memory for new "
"operating points");
diff --git a/sys/arch/amd64/amd64/ioapic.c b/sys/arch/amd64/amd64/ioapic.c
index 3815c2f2021..c18a1036cb5 100644
--- a/sys/arch/amd64/amd64/ioapic.c
+++ b/sys/arch/amd64/amd64/ioapic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioapic.c,v 1.21 2014/11/22 18:55:20 deraadt Exp $ */
+/* $OpenBSD: ioapic.c,v 1.22 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: ioapic.c,v 1.6 2003/05/15 13:30:31 fvdl Exp $ */
/*-
@@ -342,7 +342,7 @@ ioapic_attach(struct device *parent, struct device *self, void *aux)
apic_id = (ioapic_read(sc, IOAPIC_ID) & IOAPIC_ID_MASK) >>
IOAPIC_ID_SHIFT;
- sc->sc_pins = malloc(sizeof(struct ioapic_pin) * sc->sc_apic_sz,
+ sc->sc_pins = mallocarray(sc->sc_apic_sz, sizeof(struct ioapic_pin),
M_DEVBUF, M_WAITOK);
for (i = 0; i < sc->sc_apic_sz; i++) {
diff --git a/sys/arch/amd64/amd64/mpbios.c b/sys/arch/amd64/amd64/mpbios.c
index 614dbbec79e..5c083546a10 100644
--- a/sys/arch/amd64/amd64/mpbios.c
+++ b/sys/arch/amd64/amd64/mpbios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpbios.c,v 1.23 2014/11/16 12:30:56 deraadt Exp $ */
+/* $OpenBSD: mpbios.c,v 1.24 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: mpbios.c,v 1.7 2003/05/15 16:32:50 fvdl Exp $ */
/*-
@@ -601,9 +601,9 @@ mpbios_scan(struct device *self)
position += mp_conf[type].length;
}
- mp_busses = malloc(sizeof(struct mp_bus) * mp_nbusses,
+ mp_busses = mallocarray(mp_nbusses, sizeof(struct mp_bus),
M_DEVBUF, M_NOWAIT|M_ZERO);
- mp_intrs = malloc(sizeof(struct mp_intr_map) * intr_cnt,
+ mp_intrs = mallocarray(intr_cnt, sizeof(struct mp_intr_map),
M_DEVBUF, M_NOWAIT);
/* re-walk the table, recording info of interest */
diff --git a/sys/arch/amd64/amd64/via.c b/sys/arch/amd64/amd64/via.c
index d80f5cd6613..ca303873c82 100644
--- a/sys/arch/amd64/amd64/via.c
+++ b/sys/arch/amd64/amd64/via.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: via.c,v 1.17 2014/09/14 14:17:23 jsg Exp $ */
+/* $OpenBSD: via.c,v 1.18 2014/12/09 06:58:28 doug Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -155,7 +155,7 @@ viac3_crypto_newsession(u_int32_t *sidp, struct cryptoini *cri)
if (ses == NULL) {
sesn = sc->sc_nsessions;
- ses = malloc((sesn + 1) * sizeof(*ses), M_DEVBUF,
+ ses = mallocarray(sesn + 1, sizeof(*ses), M_DEVBUF,
M_NOWAIT);
if (ses == NULL)
return (ENOMEM);