summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2007-10-08 04:15:16 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2007-10-08 04:15:16 +0000
commitd0aa54a0d4ea6a5829f72c5d8e83be3a2600deca (patch)
tree00047cb58ad4a4453db399c255919b5bd3fad9b7
parent5fe5ffe7fab12d593fcc5f9f1fe293422159975c (diff)
More simple memset(,0,) -> M_ZERO changes. In this batch move to
size(*p) as the first malloc() parameter where p is declared locally and thus easy to check. Add M_ZERO to gpe_table allocation in acpi.c even though there is no obvious bzero or memset nearby.
-rw-r--r--sys/arch/alpha/pci/mcpcia.c5
-rw-r--r--sys/dev/acpi/acpi.c15
-rw-r--r--sys/dev/acpi/acpicpu.c9
-rw-r--r--sys/dev/acpi/acpimadt.c8
-rw-r--r--sys/dev/acpi/acpiprt.c5
-rw-r--r--sys/dev/acpi/dsdt.c5
-rw-r--r--sys/dev/ipmi.c8
-rw-r--r--sys/dev/pci/if_san_xilinx.c5
-rw-r--r--sys/dev/pci/qli_pci.c5
-rw-r--r--sys/xfs/xfs_vnodeops-common.c3
10 files changed, 25 insertions, 43 deletions
diff --git a/sys/arch/alpha/pci/mcpcia.c b/sys/arch/alpha/pci/mcpcia.c
index f22133bfe3e..65aaa2d3732 100644
--- a/sys/arch/alpha/pci/mcpcia.c
+++ b/sys/arch/alpha/pci/mcpcia.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mcpcia.c,v 1.1 2007/03/16 21:22:27 robert Exp $ */
+/* $OpenBSD: mcpcia.c,v 1.2 2007/10/08 04:15:15 krw Exp $ */
/* $NetBSD: mcpcia.c,v 1.20 2007/03/04 05:59:11 christos Exp $ */
/*-
@@ -179,8 +179,7 @@ mcpciaattach(parent, self, aux)
ma->ma_gid == mcpcia_console_configuration.cc_gid)
ccp = &mcpcia_console_configuration;
else {
- ccp = malloc(sizeof(struct mcpcia_config), M_DEVBUF, M_WAITOK);
- memset(ccp, 0, sizeof(struct mcpcia_config));
+ ccp = malloc(sizeof(*ccp), M_DEVBUF, M_WAITOK | M_ZERO);
ccp->cc_mid = ma->ma_mid;
ccp->cc_gid = ma->ma_gid;
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 57a782a2008..136170ad46e 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.90 2007/09/13 20:35:47 mk Exp $ */
+/* $OpenBSD: acpi.c,v 1.91 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -391,13 +391,12 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
sc->sc_powerbtn = 0;
sc->sc_sleepbtn = 0;
- sc->sc_note = malloc(sizeof(struct klist), M_DEVBUF, M_NOWAIT);
+ sc->sc_note = malloc(sizeof(struct klist), M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sc_note == NULL) {
printf(": can't allocate memory\n");
acpi_unmap(&handle);
return;
}
- memset(sc->sc_note, 0, sizeof(struct klist));
if (acpi_loadtables(sc, rsdp)) {
printf(": can't load tables\n");
@@ -595,15 +594,12 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
SLIST_INIT(&sc->sc_bat);
TAILQ_FOREACH(dev, &alldevs, dv_list) {
if (!strncmp(dev->dv_xname, "acpiac", strlen("acpiac"))) {
- ac = malloc(sizeof(struct acpi_ac), M_DEVBUF, M_WAITOK);
- memset(ac, 0, sizeof(struct acpi_ac));
+ ac = malloc(sizeof(*ac), M_DEVBUF, M_WAITOK | M_ZERO);
ac->aac_softc = (struct acpiac_softc *)dev;
SLIST_INSERT_HEAD(&sc->sc_ac, ac, aac_link);
}
if (!strncmp(dev->dv_xname, "acpibat", strlen("acpibat"))) {
- bat = malloc(sizeof(struct acpi_bat), M_DEVBUF,
- M_WAITOK);
- memset(bat, 0, sizeof(struct acpi_bat));
+ bat = malloc(sizeof(*bat), M_DEVBUF, M_WAITOK | M_ZERO);
bat->aba_softc = (struct acpibat_softc *)dev;
SLIST_INSERT_HEAD(&sc->sc_bat, bat, aba_link);
}
@@ -1074,8 +1070,7 @@ acpi_init_gpes(struct acpi_softc *sc)
/* Allocate GPE table */
sc->gpe_table = malloc(sc->sc_lastgpe * sizeof(struct gpe_block),
- M_DEVBUF, M_WAITOK);
- memset(sc->gpe_table, 0, sc->sc_lastgpe * sizeof(struct gpe_block));
+ M_DEVBUF, M_WAITOK | M_ZERO);
ngpe = 0;
diff --git a/sys/dev/acpi/acpicpu.c b/sys/dev/acpi/acpicpu.c
index 151f1acd775..95834f2c659 100644
--- a/sys/dev/acpi/acpicpu.c
+++ b/sys/dev/acpi/acpicpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpicpu.c,v 1.26 2007/06/15 22:37:40 gwk Exp $ */
+/* $OpenBSD: acpicpu.c,v 1.27 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -181,8 +181,7 @@ acpicpu_add_cstate(struct acpicpu_softc *sc, int type,
break;
}
- cx = malloc(sizeof(struct acpi_cstate), M_DEVBUF, M_WAITOK);
- memset(cx, 0, sizeof(struct acpi_cstate));
+ cx = malloc(sizeof(*cx), M_DEVBUF, M_WAITOK | M_ZERO);
cx->type = type;
cx->power = power;
@@ -455,9 +454,7 @@ acpicpu_getpss(struct acpicpu_softc *sc)
free(sc->sc_pss, M_DEVBUF);
sc->sc_pss = malloc(res.length * sizeof *sc->sc_pss, M_DEVBUF,
- M_WAITOK);
-
- memset(sc->sc_pss, 0, res.length * sizeof *sc->sc_pss);
+ M_WAITOK | M_ZERO);
for (i = 0; i < res.length; i++) {
sc->sc_pss[i].pss_core_freq = aml_val2int(
diff --git a/sys/dev/acpi/acpimadt.c b/sys/dev/acpi/acpimadt.c
index 195685e1e69..5ab8dd69d53 100644
--- a/sys/dev/acpi/acpimadt.c
+++ b/sys/dev/acpi/acpimadt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpimadt.c,v 1.10 2007/02/21 19:17:23 kettenis Exp $ */
+/* $OpenBSD: acpimadt.c,v 1.11 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2006 Mark Kettenis <kettenis@openbsd.org>
*
@@ -237,11 +237,10 @@ acpimadt_attach(struct device *parent, struct device *self, void *aux)
pin = entry->madt_override.global_int;
apic = ioapic_find_bybase(pin);
- map = malloc(sizeof (struct mp_intr_map), M_DEVBUF, M_NOWAIT);
+ map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT | M_ZERO);
if (map == NULL)
return;
- memset(map, 0, sizeof *map);
map->ioapic = apic;
map->ioapic_pin = pin - apic->sc_apic_vecbase;
map->bus_pin = entry->madt_override.source;
@@ -293,11 +292,10 @@ acpimadt_attach(struct device *parent, struct device *self, void *aux)
if (apic->sc_pins[pin].ip_map != NULL)
continue;
- map = malloc(sizeof (struct mp_intr_map), M_DEVBUF, M_NOWAIT);
+ map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT | M_ZERO);
if (map == NULL)
return;
- memset(map, 0, sizeof *map);
map->ioapic = apic;
map->ioapic_pin = pin;
map->bus_pin = pin;
diff --git a/sys/dev/acpi/acpiprt.c b/sys/dev/acpi/acpiprt.c
index 3f5c2658101..5b0d0d4b515 100644
--- a/sys/dev/acpi/acpiprt.c
+++ b/sys/dev/acpi/acpiprt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpiprt.c,v 1.17 2007/09/07 19:48:58 kettenis Exp $ */
+/* $OpenBSD: acpiprt.c,v 1.18 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2006 Mark Kettenis <kettenis@openbsd.org>
*
@@ -215,11 +215,10 @@ acpiprt_prt_add(struct acpiprt_softc *sc, struct aml_value *v)
return;
}
- map = malloc(sizeof (struct mp_intr_map), M_DEVBUF, M_NOWAIT);
+ map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT | M_ZERO);
if (map == NULL)
return;
- memset(map, 0, sizeof *map);
map->ioapic = apic;
map->ioapic_pin = irq - apic->sc_apic_vecbase;
map->bus_pin = ((addr >> 14) & 0x7c) | (pin & 0x3);
diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c
index d3e1b34605c..5b3a16d4e01 100644
--- a/sys/dev/acpi/dsdt.c
+++ b/sys/dev/acpi/dsdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsdt.c,v 1.89 2007/09/13 03:43:22 weingart Exp $ */
+/* $OpenBSD: dsdt.c,v 1.90 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
*
@@ -419,12 +419,11 @@ _acpi_os_malloc(size_t size, const char *fn, int line)
{
struct acpi_memblock *sptr;
- sptr = malloc(size+sizeof(*sptr), M_DEVBUF, M_WAITOK);
+ sptr = malloc(size+sizeof(*sptr), M_DEVBUF, M_WAITOK | M_ZERO);
dnprintf(99, "alloc: %x %s:%d\n", sptr, fn, line);
if (sptr) {
acpi_nalloc += size;
sptr->size = size;
- memset(&sptr[1], 0, size);
return &sptr[1];
}
return NULL;
diff --git a/sys/dev/ipmi.c b/sys/dev/ipmi.c
index d83e4edacb4..b5ef4e256bb 100644
--- a/sys/dev/ipmi.c
+++ b/sys/dev/ipmi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipmi.c,v 1.59 2007/08/31 18:44:50 marco Exp $ */
+/* $OpenBSD: ipmi.c,v 1.60 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave
@@ -1484,13 +1484,11 @@ add_child_sensors(struct ipmi_softc *sc, u_int8_t *psdr, int count,
return 0;
}
for (idx = 0; idx < count; idx++) {
- psensor = malloc(sizeof(struct ipmi_sensor), M_DEVBUF,
- M_NOWAIT|M_CANFAIL);
+ psensor = malloc(sizeof(*psensor), M_DEVBUF,
+ M_NOWAIT | M_CANFAIL | M_ZERO);
if (psensor == NULL)
break;
- memset(psensor, 0, sizeof(struct ipmi_sensor));
-
/* Initialize BSD Sensor info */
psensor->i_sdr = psdr;
psensor->i_num = sensor_num + idx;
diff --git a/sys/dev/pci/if_san_xilinx.c b/sys/dev/pci/if_san_xilinx.c
index dbcd6b91a13..98c4f9fb2b8 100644
--- a/sys/dev/pci/if_san_xilinx.c
+++ b/sys/dev/pci/if_san_xilinx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_san_xilinx.c,v 1.20 2007/09/17 01:33:33 krw Exp $ */
+/* $OpenBSD: if_san_xilinx.c,v 1.21 2007/10/08 04:15:15 krw Exp $ */
/*-
* Copyright (c) 2001-2004 Sangoma Technologies (SAN)
@@ -343,11 +343,10 @@ wan_xilinx_init(sdla_t *card)
timeout_set(&card->u.xilinx.led_timer, aft_led_timer, (void *)card);
/* allocate and initialize private data */
- sc = malloc(sizeof(xilinx_softc_t), M_DEVBUF, M_NOWAIT);
+ sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc == NULL)
return (NULL);
- memset(sc, 0, sizeof(xilinx_softc_t));
ifp = (struct ifnet *)&sc->common.ifp;
ifp->if_softc = sc;
sc->common.card = card;
diff --git a/sys/dev/pci/qli_pci.c b/sys/dev/pci/qli_pci.c
index bc6e845b5b5..32525ef09be 100644
--- a/sys/dev/pci/qli_pci.c
+++ b/sys/dev/pci/qli_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: qli_pci.c,v 1.10 2007/09/29 16:03:43 marco Exp $ */
+/* $OpenBSD: qli_pci.c,v 1.11 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2007 David Collins <dave@davec.name>
@@ -302,11 +302,10 @@ qli_allocmem(struct qli_softc *sc, size_t size)
DNPRINTF(QLI_D_MEM, "%s: qli_allocmem: %d\n", DEVNAME(sc),
size);
- mm = malloc(sizeof(struct qli_mem), M_DEVBUF, M_NOWAIT);
+ mm = malloc(sizeof(*mm), M_DEVBUF, M_NOWAIT | M_ZERO);
if (mm == NULL)
return (NULL);
- memset(mm, 0, sizeof(struct qli_mem));
mm->am_size = size;
if (bus_dmamap_create(sc->sc_dmat, size, 1, size, 0,
diff --git a/sys/xfs/xfs_vnodeops-common.c b/sys/xfs/xfs_vnodeops-common.c
index ecb61f8d839..9531c0a719a 100644
--- a/sys/xfs/xfs_vnodeops-common.c
+++ b/sys/xfs/xfs_vnodeops-common.c
@@ -931,12 +931,11 @@ xfs_symlink_common(struct vnode *dvp,
NNPFSDEB(XDEBVNOPS, ("xfs_symlink: %s\n", name));
- msg = malloc(sizeof(struct xfs_message_symlink), M_TEMP, M_WAITOK);
+ msg = malloc(sizeof(*msg), M_TEMP, M_WAITOK | M_ZERO);
if (msg == NULL) {
error = ENOMEM;
goto done;
}
- memset(msg, 0, sizeof(*msg));
msg->header.opcode = NNPFS_MSG_SYMLINK;
msg->parent_handle = xn->handle;