diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-09-17 01:33:34 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-09-17 01:33:34 +0000 |
commit | a854e6884a9635329a1490f5cf8420c8ab6f8f85 (patch) | |
tree | 29bd971e80c3ea6bf34f989e494141dcc2c006cb /sys/dev | |
parent | 1dd97578d5974d04f8b171b17c36e35635acd61b (diff) |
Only the most obvious bzero() -> M_ZERO changes. No cast changes, no
MALLOC/FREE, etc. Just adding M_ZERO to malloc() and deleting an
immediately adjacent bzero().
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/if_wi.c | 41 | ||||
-rw-r--r-- | sys/dev/ic/rtw.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/agp.c | 8 | ||||
-rw-r--r-- | sys/dev/pci/agp_i810.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/if_san_xilinx.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/ips.c | 5 | ||||
-rw-r--r-- | sys/dev/sdmmc/sdmmc_io.c | 5 | ||||
-rw-r--r-- | sys/dev/wscons/wsmux.c | 5 | ||||
-rw-r--r-- | sys/dev/wsfont/wsfont.c | 6 |
9 files changed, 32 insertions, 54 deletions
diff --git a/sys/dev/ic/if_wi.c b/sys/dev/ic/if_wi.c index 8de7abf4a19..30520bfb12e 100644 --- a/sys/dev/ic/if_wi.c +++ b/sys/dev/ic/if_wi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi.c,v 1.137 2006/11/26 19:46:28 deraadt Exp $ */ +/* $OpenBSD: if_wi.c,v 1.138 2007/09/17 01:33:33 krw Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -126,7 +126,7 @@ u_int32_t widebug = WIDEBUG; #if !defined(lint) && !defined(__OpenBSD__) static const char rcsid[] = - "$OpenBSD: if_wi.c,v 1.137 2006/11/26 19:46:28 deraadt Exp $"; + "$OpenBSD: if_wi.c,v 1.138 2007/09/17 01:33:33 krw Exp $"; #endif /* lint */ #ifdef foo @@ -1644,8 +1644,7 @@ wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data) error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, command); break; case SIOCGWAVELAN: - wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK); - bzero(wreq, sizeof(*wreq)); + wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK | M_ZERO); error = copyin(ifr->ifr_data, wreq, sizeof(*wreq)); if (error) break; @@ -1702,8 +1701,7 @@ wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data) case SIOCSWAVELAN: if ((error = suser(curproc, 0)) != 0) break; - wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK); - bzero(wreq, sizeof(*wreq)); + wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK | M_ZERO); error = copyin(ifr->ifr_data, wreq, sizeof(*wreq)); if (error) break; @@ -1770,8 +1768,7 @@ wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data) } break; case SIOCGPRISM2DEBUG: - wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK); - bzero(wreq, sizeof(*wreq)); + wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK | M_ZERO); error = copyin(ifr->ifr_data, wreq, sizeof(*wreq)); if (error) break; @@ -1787,8 +1784,7 @@ wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data) case SIOCSPRISM2DEBUG: if ((error = suser(curproc, 0)) != 0) break; - wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK); - bzero(wreq, sizeof(*wreq)); + wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK | M_ZERO); error = copyin(ifr->ifr_data, wreq, sizeof(*wreq)); if (error) break; @@ -1800,16 +1796,15 @@ wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data) error = copyout(&sc->wi_net_name, ifr->ifr_data, sizeof(sc->wi_net_name)); } else { - wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK); - bzero(wreq, sizeof(*wreq)); + wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK|M_ZERO); wreq->wi_type = WI_RID_CURRENT_SSID; wreq->wi_len = WI_MAX_DATALEN; if (wi_read_record(sc, (struct wi_ltv_gen *)wreq) || letoh16(wreq->wi_val[0]) > IEEE80211_NWID_LEN) error = EINVAL; else { - nwidp = malloc(sizeof *nwidp, M_DEVBUF, M_WAITOK); - bzero(nwidp, sizeof(*nwidp)); + nwidp = malloc(sizeof *nwidp, M_DEVBUF, + M_WAITOK | M_ZERO); wi_set_ssid(nwidp, (u_int8_t *)&wreq->wi_val[1], letoh16(wreq->wi_val[0])); error = copyout(nwidp, ifr->ifr_data, @@ -1868,8 +1863,7 @@ wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data) error = EINVAL; break; } - wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK); - bzero(wreq, sizeof(*wreq)); + wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK | M_ZERO); wreq->wi_type = WI_RID_OWN_CHNL; wreq->wi_val[0] = htole16(((struct ieee80211chanreq *)data)->i_channel); @@ -1878,8 +1872,7 @@ wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data) wi_init(sc); break; case SIOCG80211CHANNEL: - wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK); - bzero(wreq, sizeof(*wreq)); + wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK | M_ZERO); wreq->wi_type = WI_RID_CURRENT_CHAN; wreq->wi_len = WI_MAX_DATALEN; if (wi_read_record(sc, (struct wi_ltv_gen *)wreq)) { @@ -1891,8 +1884,7 @@ wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data) break; case SIOCG80211BSSID: bssid = (struct ieee80211_bssid *)data; - wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK); - bzero(wreq, sizeof(*wreq)); + wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK | M_ZERO); wreq->wi_type = WI_RID_CURRENT_BSSID; wreq->wi_len = WI_MAX_DATALEN; if (wi_read_record(sc, (struct wi_ltv_gen *)wreq)) { @@ -1914,8 +1906,7 @@ wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data) wi_cmd(sc, WI_CMD_INQUIRE, WI_INFO_SCAN_RESULTS, 0, 0); } else { - wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK); - bzero(wreq, sizeof(*wreq)); + wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK|M_ZERO); wreq->wi_len = 3; wreq->wi_type = WI_RID_SCAN_REQ; wreq->wi_val[0] = 0x3FFF; @@ -1951,8 +1942,7 @@ wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data) error = wihap_ioctl(sc, command, data); break; } - wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK); - bzero(wreq, sizeof(*wreq)); + wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK | M_ZERO); wreq->wi_len = WI_MAX_DATALEN; wreq->wi_type = WI_RID_SCAN_RES; if (sc->sc_firmware_type == WI_LUCENT) { @@ -2026,8 +2016,7 @@ wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data) break; ifr->ifr_flags = 0; if (sc->wi_flags & WI_FLAGS_HAS_ENH_SECURITY) { - wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK); - bzero(wreq, sizeof(*wreq)); + wreq = malloc(sizeof *wreq, M_DEVBUF, M_WAITOK|M_ZERO); wreq->wi_len = WI_MAX_DATALEN; wreq->wi_type = WI_RID_ENH_SECURITY; if (wi_read_record(sc, (struct wi_ltv_gen *)wreq)) { diff --git a/sys/dev/ic/rtw.c b/sys/dev/ic/rtw.c index 50dafe4da42..43e2f99412b 100644 --- a/sys/dev/ic/rtw.c +++ b/sys/dev/ic/rtw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtw.c,v 1.61 2007/06/07 20:20:15 damien Exp $ */ +/* $OpenBSD: rtw.c,v 1.62 2007/09/17 01:33:33 krw Exp $ */ /* $NetBSD: rtw.c,v 1.29 2004/12/27 19:49:16 dyoung Exp $ */ /*- @@ -664,15 +664,13 @@ rtw_srom_read(struct rtw_regs *regs, u_int32_t flags, struct rtw_srom *sr, RTW_WRITE8(regs, RTW_9346CR, ecr); - sr->sr_content = malloc(sr->sr_size, M_DEVBUF, M_NOWAIT); + sr->sr_content = malloc(sr->sr_size, M_DEVBUF, M_NOWAIT | M_ZERO); if (sr->sr_content == NULL) { printf("%s: unable to allocate SROM buffer\n", dvname); return ENOMEM; } - bzero(sr->sr_content, sr->sr_size); - /* RTL8180 has a single 8-bit register for controlling the * 93cx6 SROM. There is no "ready" bit. The RTL8180 * input/output sense is the reverse of read_seeprom's. diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c index 20147866804..52faa49e477 100644 --- a/sys/dev/pci/agp.c +++ b/sys/dev/pci/agp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp.c,v 1.6 2007/08/04 19:40:25 reyk Exp $ */ +/* $OpenBSD: agp.c,v 1.7 2007/09/17 01:33:33 krw Exp $ */ /*- * Copyright (c) 2000 Doug Rabson * All rights reserved. @@ -372,10 +372,9 @@ agp_alloc_gatt(struct vga_pci_softc *sc) struct agp_gatt *gatt; int nseg; - gatt = malloc(sizeof(*gatt), M_DEVBUF, M_NOWAIT); + gatt = malloc(sizeof(*gatt), M_DEVBUF, M_NOWAIT | M_ZERO); if (!gatt) return (NULL); - bzero(gatt, sizeof(*gatt)); gatt->ag_entries = entries; if (agp_alloc_dmamem(sc->sc_dmat, entries * sizeof(u_int32_t), @@ -474,10 +473,9 @@ agp_generic_alloc_memory(struct vga_pci_softc *sc, int type, vsize_t size) return 0; } - mem = malloc(sizeof *mem, M_DEVBUF, M_WAITOK); + mem = malloc(sizeof *mem, M_DEVBUF, M_WAITOK | M_ZERO); if (mem == NULL) return NULL; - bzero(mem, sizeof *mem); if (bus_dmamap_create(sc->sc_dmat, size, size / PAGE_SIZE + 1, size, 0, BUS_DMA_NOWAIT, &mem->am_dmamap) != 0) { diff --git a/sys/dev/pci/agp_i810.c b/sys/dev/pci/agp_i810.c index 916873b5a8c..d405e3d4e89 100644 --- a/sys/dev/pci/agp_i810.c +++ b/sys/dev/pci/agp_i810.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_i810.c,v 1.15 2007/08/04 19:40:25 reyk Exp $ */ +/* $OpenBSD: agp_i810.c,v 1.16 2007/09/17 01:33:33 krw Exp $ */ /* $NetBSD: agp_i810.c,v 1.15 2003/01/31 00:07:39 thorpej Exp $ */ /*- @@ -680,8 +680,7 @@ agp_i810_alloc_memory(struct vga_pci_softc *sc, int type, vsize_t size) } } - mem = malloc(sizeof *mem, M_DEVBUF, M_WAITOK); - bzero(mem, sizeof *mem); + mem = malloc(sizeof *mem, M_DEVBUF, M_WAITOK | M_ZERO); mem->am_id = sc->sc_nextid++; mem->am_size = size; mem->am_type = type; diff --git a/sys/dev/pci/if_san_xilinx.c b/sys/dev/pci/if_san_xilinx.c index 7c85bf0f1ed..dbcd6b91a13 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.19 2007/09/12 13:56:40 chl Exp $ */ +/* $OpenBSD: if_san_xilinx.c,v 1.20 2007/09/17 01:33:33 krw Exp $ */ /*- * Copyright (c) 2001-2004 Sangoma Technologies (SAN) @@ -2390,11 +2390,10 @@ aft_alloc_rx_buffers(xilinx_softc_t *sc) SIMPLEQ_INIT(&sc->wp_rx_complete_list); /* allocate receive buffers in one cluster */ - buf = malloc(sizeof(*buf) * MAX_RX_BUF, M_DEVBUF, M_NOWAIT); + buf = malloc(sizeof(*buf) * MAX_RX_BUF, M_DEVBUF, M_NOWAIT | M_ZERO); if (buf == NULL) return (1); - bzero(buf, sizeof(*buf) * MAX_RX_BUF); sc->wp_rx_buffers = buf; sc->wp_rx_buffer_last = buf; diff --git a/sys/dev/pci/ips.c b/sys/dev/pci/ips.c index 97785355ab5..db873c0c345 100644 --- a/sys/dev/pci/ips.c +++ b/sys/dev/pci/ips.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ips.c,v 1.29 2007/06/06 20:51:13 grange Exp $ */ +/* $OpenBSD: ips.c,v 1.30 2007/09/17 01:33:33 krw Exp $ */ /* * Copyright (c) 2006, 2007 Alexander Yurchenko <grange@openbsd.org> @@ -951,9 +951,8 @@ ips_ccb_alloc(struct ips_softc *sc, int n) struct ips_ccb *ccb; int i; - if ((ccb = malloc(n * sizeof(*ccb), M_DEVBUF, M_NOWAIT)) == NULL) + if ((ccb = malloc(n * sizeof(*ccb), M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) return (NULL); - bzero(ccb, n * sizeof(*ccb)); for (i = 0; i < n; i++) { ccb[i].c_id = i; diff --git a/sys/dev/sdmmc/sdmmc_io.c b/sys/dev/sdmmc/sdmmc_io.c index 07d0cea898f..839740ee8be 100644 --- a/sys/dev/sdmmc/sdmmc_io.c +++ b/sys/dev/sdmmc/sdmmc_io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdmmc_io.c,v 1.9 2007/06/02 01:48:37 uwe Exp $ */ +/* $OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org> @@ -611,11 +611,10 @@ sdmmc_intr_establish(struct device *sdmmc, int (*fun)(void *), if (sc->sct->card_intr_mask == NULL) return NULL; - ih = malloc(sizeof *ih, M_DEVBUF, M_WAITOK | M_CANFAIL); + ih = malloc(sizeof *ih, M_DEVBUF, M_WAITOK | M_CANFAIL | M_ZERO); if (ih == NULL) return NULL; - bzero(ih, sizeof *ih); ih->ih_name = malloc(strlen(name), M_DEVBUF, M_WAITOK | M_CANFAIL); if (ih->ih_name == NULL) { free(ih, M_DEVBUF); diff --git a/sys/dev/wscons/wsmux.c b/sys/dev/wscons/wsmux.c index 59576f16c67..d112081b4cb 100644 --- a/sys/dev/wscons/wsmux.c +++ b/sys/dev/wscons/wsmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmux.c,v 1.20 2007/05/14 09:03:34 tedu Exp $ */ +/* $OpenBSD: wsmux.c,v 1.21 2007/09/17 01:33:33 krw Exp $ */ /* $NetBSD: wsmux.c,v 1.37 2005/04/30 03:47:12 augustss Exp $ */ /* @@ -589,10 +589,9 @@ wsmux_create(const char *name, int unit) struct wsmux_softc *sc; DPRINTF(("wsmux_create: allocating\n")); - sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT); + sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT | M_ZERO); if (sc == NULL) return (NULL); - bzero(sc, sizeof *sc); CIRCLEQ_INIT(&sc->sc_cld); snprintf(sc->sc_base.me_dv.dv_xname, sizeof sc->sc_base.me_dv.dv_xname, "%s%d", name, unit); diff --git a/sys/dev/wsfont/wsfont.c b/sys/dev/wsfont/wsfont.c index 2bd7287a5ad..8b438310961 100644 --- a/sys/dev/wsfont/wsfont.c +++ b/sys/dev/wsfont/wsfont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsfont.c,v 1.21 2007/09/10 19:49:31 gilles Exp $ */ +/* $OpenBSD: wsfont.c,v 1.22 2007/09/17 01:33:33 krw Exp $ */ /* $NetBSD: wsfont.c,v 1.17 2001/02/07 13:59:24 ad Exp $ */ /*- @@ -313,14 +313,12 @@ wsfont_rotate_internal(struct wsdisplay_font *font) /* Allocate a buffer big enough for the rotated font. */ newstride = (font->fontheight + 7) / 8; newbits = malloc(newstride * font->fontwidth * font->numchars, - M_DEVBUF, M_WAITOK); + M_DEVBUF, M_WAITOK | M_ZERO); if (newbits == NULL) { free(newfont, M_DEVBUF); return (NULL); } - bzero(newbits, newstride * font->fontwidth * font->numchars); - /* Rotate the font a bit at a time. */ for (n = 0; n < font->numchars; n++) { char *ch = font->data + (n * font->stride * font->fontheight); |