summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64
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/sparc64
parent7ac588b8eb1d276029001886214facee144b2fc5 (diff)
Replace some malloc(n*size,...) calls with mallocarray().
ok tedu@ deraadt@
Diffstat (limited to 'sys/arch/sparc64')
-rw-r--r--sys/arch/sparc64/dev/pyro.c6
-rw-r--r--sys/arch/sparc64/dev/sbus.c5
-rw-r--r--sys/arch/sparc64/dev/vdsp.c8
-rw-r--r--sys/arch/sparc64/dev/vpci.c6
4 files changed, 13 insertions, 12 deletions
diff --git a/sys/arch/sparc64/dev/pyro.c b/sys/arch/sparc64/dev/pyro.c
index d79cb427d4e..668ee637603 100644
--- a/sys/arch/sparc64/dev/pyro.c
+++ b/sys/arch/sparc64/dev/pyro.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pyro.c,v 1.27 2014/07/12 18:44:43 tedu Exp $ */
+/* $OpenBSD: pyro.c,v 1.28 2014/12/09 06:58:29 doug Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -304,8 +304,8 @@ pyro_init_msi(struct pyro_softc *sc, struct pyro_pbm *pbm)
pbm->pp_msiaddr |= ((bus_addr_t)msi_addr_range[0]) << 32;
msis = getpropint(sc->sc_node, "#msi", 256);
- pbm->pp_msi = malloc(msis * sizeof(*pbm->pp_msi),
- M_DEVBUF, M_NOWAIT | M_ZERO);
+ pbm->pp_msi = mallocarray(msis, sizeof(*pbm->pp_msi), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
if (pbm->pp_msi == NULL)
return;
diff --git a/sys/arch/sparc64/dev/sbus.c b/sys/arch/sparc64/dev/sbus.c
index c4efd70b7cc..098e85381a3 100644
--- a/sys/arch/sparc64/dev/sbus.c
+++ b/sys/arch/sparc64/dev/sbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbus.c,v 1.42 2014/07/12 20:18:09 uebayasi Exp $ */
+/* $OpenBSD: sbus.c,v 1.43 2014/12/09 06:58:29 doug Exp $ */
/* $NetBSD: sbus.c,v 1.46 2001/10/07 20:30:41 eeh Exp $ */
/*-
@@ -600,7 +600,8 @@ sbus_get_intr(struct sbus_softc *sc, int node, struct sbus_intr **ipp, int *np,
pri = INTLEVENCODE(2);
/* Change format to an `struct sbus_intr' array */
- ip = malloc(*np * sizeof(struct sbus_intr), M_DEVBUF, M_NOWAIT);
+ ip = mallocarray(*np, sizeof(struct sbus_intr), M_DEVBUF,
+ M_NOWAIT);
if (ip == NULL)
return (ENOMEM);
diff --git a/sys/arch/sparc64/dev/vdsp.c b/sys/arch/sparc64/dev/vdsp.c
index 3813138e74c..9e394d8ffca 100644
--- a/sys/arch/sparc64/dev/vdsp.c
+++ b/sys/arch/sparc64/dev/vdsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vdsp.c,v 1.32 2014/09/29 19:34:23 kettenis Exp $ */
+/* $OpenBSD: vdsp.c,v 1.33 2014/12/09 06:58:29 doug Exp $ */
/*
* Copyright (c) 2009, 2011, 2014 Mark Kettenis
*
@@ -1080,10 +1080,10 @@ vdsp_alloc(void *arg1, void *arg2)
KASSERT(sc->sc_num_descriptors <= VDSK_MAX_DESCRIPTORS);
KASSERT(sc->sc_descriptor_size <= VDSK_MAX_DESCRIPTOR_SIZE);
- sc->sc_vd = malloc(sc->sc_num_descriptors * sc->sc_descriptor_size,
- M_DEVBUF, M_WAITOK);
- sc->sc_vd_task = malloc(sc->sc_num_descriptors * sizeof(struct task),
+ sc->sc_vd = mallocarray(sc->sc_num_descriptors, sc->sc_descriptor_size,
M_DEVBUF, M_WAITOK);
+ sc->sc_vd_task = mallocarray(sc->sc_num_descriptors,
+ sizeof(struct task), M_DEVBUF, M_WAITOK);
bzero(&dr, sizeof(dr));
dr.tag.type = VIO_TYPE_CTRL;
diff --git a/sys/arch/sparc64/dev/vpci.c b/sys/arch/sparc64/dev/vpci.c
index 6e86ec1b63c..0633a7cfded 100644
--- a/sys/arch/sparc64/dev/vpci.c
+++ b/sys/arch/sparc64/dev/vpci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vpci.c,v 1.17 2014/11/24 22:41:12 kettenis Exp $ */
+/* $OpenBSD: vpci.c,v 1.18 2014/12/09 06:58:29 doug Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org>
*
@@ -241,8 +241,8 @@ vpci_init_msi(struct vpci_softc *sc, struct vpci_pbm *pbm)
pbm->vp_msiaddr |= ((bus_addr_t)msi_addr_range[0]) << 32;
msis = getpropint(sc->sc_node, "#msi", 256);
- pbm->vp_msi = malloc(msis * sizeof(*pbm->vp_msi),
- M_DEVBUF, M_NOWAIT | M_ZERO);
+ pbm->vp_msi = mallocarray(msis, sizeof(*pbm->vp_msi), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
if (pbm->vp_msi == NULL)
return;