summaryrefslogtreecommitdiffstats
path: root/sys/arch
diff options
context:
space:
mode:
authordoug <doug@openbsd.org>2014-12-13 21:05:32 +0000
committerdoug <doug@openbsd.org>2014-12-13 21:05:32 +0000
commitf8238f3e71a8eb02e65b90db598fa2664cb0a2c7 (patch)
treed1d22656f8480e9375f3f277691d9ca2527e7d8e /sys/arch
parentSort members by size to reduce structure padding (diff)
downloadwireguard-openbsd-f8238f3e71a8eb02e65b90db598fa2664cb0a2c7.tar.xz
wireguard-openbsd-f8238f3e71a8eb02e65b90db598fa2664cb0a2c7.zip
yet more mallocarray() changes.
ok tedu@ deraadt@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/alpha/tc/tc_dma_3000_500.c7
-rw-r--r--sys/arch/arm/cortex/ampintc.c7
-rw-r--r--sys/arch/sgi/dev/impact.c9
3 files changed, 10 insertions, 13 deletions
diff --git a/sys/arch/alpha/tc/tc_dma_3000_500.c b/sys/arch/alpha/tc/tc_dma_3000_500.c
index a38a848121f..c21e0f54452 100644
--- a/sys/arch/alpha/tc/tc_dma_3000_500.c
+++ b/sys/arch/alpha/tc/tc_dma_3000_500.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tc_dma_3000_500.c,v 1.5 2009/02/01 14:34:02 miod Exp $ */
+/* $OpenBSD: tc_dma_3000_500.c,v 1.6 2014/12/13 21:05:32 doug Exp $ */
/* $NetBSD: tc_dma_3000_500.c,v 1.13 2001/07/19 06:40:03 thorpej Exp $ */
/*-
@@ -81,12 +81,11 @@ tc_dma_init_3000_500(nslots)
int nslots;
{
extern struct alpha_bus_dma_tag tc_dmat_direct;
- size_t sisize;
int i;
/* Allocate per-slot DMA info. */
- sisize = nslots * sizeof(struct tc_dma_slot_info);
- tc_dma_slot_info = malloc(sisize, M_DEVBUF, M_NOWAIT | M_ZERO);
+ tc_dma_slot_info = mallocarray(nslots, sizeof(struct tc_dma_slot_info),
+ M_DEVBUF, M_NOWAIT | M_ZERO);
if (tc_dma_slot_info == NULL)
panic("tc_dma_init: can't allocate per-slot DMA info");
diff --git a/sys/arch/arm/cortex/ampintc.c b/sys/arch/arm/cortex/ampintc.c
index 7a7b2d1f567..d9aa90d71fc 100644
--- a/sys/arch/arm/cortex/ampintc.c
+++ b/sys/arch/arm/cortex/ampintc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ampintc.c,v 1.4 2014/10/08 14:53:36 rapha Exp $ */
+/* $OpenBSD: ampintc.c,v 1.5 2014/12/13 21:05:32 doug Exp $ */
/*
* Copyright (c) 2007,2009,2011 Dale Rahn <drahn@openbsd.org>
*
@@ -268,9 +268,8 @@ ampintc_attach(struct device *parent, struct device *self, void *args)
/* XXX - check power saving bit */
- sc->sc_ampintc_handler = malloc(
- (sizeof (*sc->sc_ampintc_handler) * nintr),
- M_DEVBUF, M_ZERO | M_NOWAIT);
+ sc->sc_ampintc_handler = mallocarray(nintr,
+ sizeof(*sc->sc_ampintc_handler), M_DEVBUF, M_ZERO | M_NOWAIT);
for (i = 0; i < nintr; i++) {
TAILQ_INIT(&sc->sc_ampintc_handler[i].iq_list);
}
diff --git a/sys/arch/sgi/dev/impact.c b/sys/arch/sgi/dev/impact.c
index 633f85888d8..dc5481fcbb9 100644
--- a/sys/arch/sgi/dev/impact.c
+++ b/sys/arch/sgi/dev/impact.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: impact.c,v 1.6 2014/07/12 18:44:42 tedu Exp $ */
+/* $OpenBSD: impact.c,v 1.7 2014/12/13 21:05:32 doug Exp $ */
/*
* Copyright (c) 2010, 2012 Miodrag Vallat.
@@ -192,7 +192,6 @@ int
impact_init_screen(struct impact_screen *scr)
{
struct rasops_info *ri = &scr->ri;
- size_t bssize;
int i;
uint32_t c, r, g, b;
@@ -211,9 +210,9 @@ impact_init_screen(struct impact_screen *scr)
* be able to fulfill scrolling requests.
*/
if (scr->bs == NULL) {
- bssize = ri->ri_rows * ri->ri_cols *
- sizeof(struct wsdisplay_charcell);
- scr->bs = malloc(bssize, M_DEVBUF, M_NOWAIT | M_ZERO);
+ scr->bs = mallocarray(ri->ri_rows,
+ ri->ri_cols * sizeof(struct wsdisplay_charcell), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
if (scr->bs == NULL)
return ENOMEM;
}