constants.
The consensus is that if both operands are constant, we don't need
mallocarray. Reminded by tedu@
ok deraadt@
-/* $OpenBSD: aac.c,v 1.69 2017/04/09 18:07:19 dhill Exp $ */
+/* $OpenBSD: aac.c,v 1.70 2017/04/11 14:43:49 dhill Exp $ */
/*-
* Copyright (c) 2000 Michael Smith
/* Allocate some FIBs and associated command structs */
TAILQ_INIT(&sc->aac_fibmap_tqh);
- sc->aac_commands = mallocarray(AAC_MAX_FIBS, sizeof(struct aac_command),
+ sc->aac_commands = malloc(AAC_MAX_FIBS * sizeof(struct aac_command),
M_DEVBUF, M_WAITOK | M_ZERO);
while (sc->total_fibs < AAC_MAX_FIBS) {
if (aac_alloc_commands(sc) != 0)
-/* $OpenBSD: adw.c,v 1.53 2017/04/09 18:07:19 dhill Exp $ */
+/* $OpenBSD: adw.c,v 1.54 2017/04/11 14:43:49 dhill Exp $ */
/* $NetBSD: adw.c,v 1.23 2000/05/27 18:24:50 dante Exp $ */
/*
* Allocate the control structure.
*/
sc->sc_control->carriers =
- mallocarray(ADW_MAX_CARRIER, sizeof(ADW_CARRIER), M_DEVBUF,
+ malloc(ADW_MAX_CARRIER * sizeof(ADW_CARRIER), M_DEVBUF,
M_NOWAIT);
if (sc->sc_control->carriers == NULL)
return (ENOMEM);
-/* $OpenBSD: ath.c,v 1.113 2017/04/09 18:07:19 dhill Exp $ */
+/* $OpenBSD: ath.c,v 1.114 2017/04/11 14:43:49 dhill Exp $ */
/* $NetBSD: ath.c,v 1.37 2004/08/18 21:59:39 dyoung Exp $ */
/*-
int i, ix, nchan;
sc->sc_nchan = 0;
- chans = mallocarray(IEEE80211_CHAN_MAX, sizeof(HAL_CHANNEL),
+ chans = malloc(IEEE80211_CHAN_MAX * sizeof(HAL_CHANNEL),
M_TEMP, M_NOWAIT);
if (chans == NULL) {
printf("%s: unable to allocate channel table\n", ifp->if_xname);
-/* $OpenBSD: azalia.c,v 1.234 2017/04/09 18:16:00 dhill Exp $ */
+/* $OpenBSD: azalia.c,v 1.235 2017/04/11 14:43:49 dhill Exp $ */
/* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */
/*-
DPRINTF(("%s: RIRB allocation succeeded.\n", __func__));
/* setup the unsolicited response queue */
- az->unsolq = mallocarray(UNSOLQ_SIZE, sizeof(rirb_entry_t),
+ az->unsolq = malloc(sizeof(rirb_entry_t) * UNSOLQ_SIZE,
M_DEVBUF, M_NOWAIT | M_ZERO);
if (az->unsolq == NULL) {
DPRINTF(("%s: can't allocate unsolicited response queue.\n",
-/* $OpenBSD: if_dc_pci.c,v 1.75 2017/04/09 18:16:00 dhill Exp $ */
+/* $OpenBSD: if_dc_pci.c,v 1.76 2017/04/11 14:43:49 dhill Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
sc->dc_type = DC_TYPE_PNIC;
sc->dc_flags |= DC_TX_STORENFWD|DC_TX_INTR_ALWAYS;
sc->dc_flags |= DC_PNIC_RX_BUG_WAR;
- sc->dc_pnic_rx_buf = mallocarray(5, ETHER_MAX_DIX_LEN,
+ sc->dc_pnic_rx_buf = malloc(ETHER_MAX_DIX_LEN * 5,
M_DEVBUF, M_NOWAIT);
if (sc->dc_pnic_rx_buf == NULL)
panic("dc_pci_attach");
-/* $OpenBSD: if_nep.c,v 1.29 2017/04/09 19:59:43 deraadt Exp $ */
+/* $OpenBSD: if_nep.c,v 1.30 2017/04/11 14:43:49 dhill Exp $ */
/*
* Copyright (c) 2014, 2015 Mark Kettenis
*
return;
sc->sc_rbdesc = NEP_DMA_KVA(sc->sc_rbring);
- sc->sc_rb = mallocarray(NEP_NRBDESC, sizeof(struct nep_block),
+ sc->sc_rb = malloc(sizeof(struct nep_block) * NEP_NRBDESC,
M_DEVBUF, M_WAITOK);
for (i = 0; i < NEP_NRBDESC; i++) {
rb = &sc->sc_rb[i];
goto free_rxmbox;
sc->sc_txdesc = NEP_DMA_KVA(sc->sc_txring);
- sc->sc_txbuf = mallocarray(NEP_NTXDESC, sizeof(struct nep_buf),
+ sc->sc_txbuf = malloc(sizeof(struct nep_buf) * NEP_NTXDESC,
M_DEVBUF, M_WAITOK);
for (i = 0; i < NEP_NTXDESC; i++) {
txb = &sc->sc_txbuf[i];
-/* $OpenBSD: dwc2_hcd.c,v 1.17 2017/04/09 18:09:41 dhill Exp $ */
+/* $OpenBSD: dwc2_hcd.c,v 1.18 2017/04/11 14:43:49 dhill Exp $ */
/* $NetBSD: dwc2_hcd.c,v 1.15 2014/11/24 10:14:14 skrll Exp $ */
/*
dev_dbg(hsotg->dev, "hcfg=%08x\n", DWC2_READ_4(hsotg, HCFG));
#ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
- hsotg->frame_num_array = mallocarray(FRAME_NUM_ARRAY_SIZE,
- sizeof(*hsotg->frame_num_array),
- M_DEVBUF, M_ZERO | M_WAITOK);
+ hsotg->frame_num_array = malloc(sizeof(*hsotg->frame_num_array) *
+ FRAME_NUM_ARRAY_SIZE, M_DEVBUF,
+ M_ZERO | M_WAITOK);
if (!hsotg->frame_num_array)
goto error1;
- hsotg->last_frame_num_array = mallocarray(FRAME_NUM_ARRAY_SIZE,
- sizeof(*hsotg->last_frame_num_array),
- M_DEVBUF, M_ZERO | M_WAITOK);
+ hsotg->last_frame_num_array = malloc(
+ sizeof(*hsotg->last_frame_num_array) *
+ FRAME_NUM_ARRAY_SIZE, M_DEVBUF, M_ZERO | M_WAITOK);
if (!hsotg->last_frame_num_array)
goto error1;
hsotg->last_frame_num = HFNUM_MAX_FRNUM;
-/* $OpenBSD: wsemul_vt100.c,v 1.34 2017/04/09 18:05:17 dhill Exp $ */
+/* $OpenBSD: wsemul_vt100.c,v 1.35 2017/04/11 14:43:49 dhill Exp $ */
/* $NetBSD: wsemul_vt100.c,v 1.13 2000/04/28 21:56:16 mycroft Exp $ */
/*
edp->dblwid = malloc(edp->nrows, M_DEVBUF, M_NOWAIT | M_ZERO);
edp->dw = 0;
edp->dcsarg = malloc(DCS_MAXLEN, M_DEVBUF, M_NOWAIT);
- edp->isolatin1tab = mallocarray(128, sizeof(u_int), M_DEVBUF, M_NOWAIT);
- edp->decgraphtab = mallocarray(128, sizeof(u_int), M_DEVBUF, M_NOWAIT);
- edp->dectechtab = mallocarray(128, sizeof(u_int), M_DEVBUF, M_NOWAIT);
- edp->nrctab = mallocarray(128, sizeof(u_int), M_DEVBUF, M_NOWAIT);
+ edp->isolatin1tab = malloc(128 * sizeof(u_int), M_DEVBUF, M_NOWAIT);
+ edp->decgraphtab = malloc(128 * sizeof(u_int), M_DEVBUF, M_NOWAIT);
+ edp->dectechtab = malloc(128 * sizeof(u_int), M_DEVBUF, M_NOWAIT);
+ edp->nrctab = malloc(128 * sizeof(u_int), M_DEVBUF, M_NOWAIT);
vt100_initchartables(edp);
wsemul_vt100_reset(edp);
return (edp);
-/* $OpenBSD: wsevent.c,v 1.16 2017/04/09 18:05:17 dhill Exp $ */
+/* $OpenBSD: wsevent.c,v 1.17 2017/04/11 14:43:49 dhill Exp $ */
/* $NetBSD: wsevent.c,v 1.16 2003/08/07 16:31:29 agc Exp $ */
/*
return;
}
ev->get = ev->put = 0;
- ev->q = mallocarray(WSEVENT_QSIZE, sizeof(struct wscons_event),
+ ev->q = malloc(WSEVENT_QSIZE * sizeof(struct wscons_event),
M_DEVBUF, M_WAITOK | M_ZERO);
}
-/* $OpenBSD: if_pfsync.c,v 1.248 2017/04/09 17:57:58 dhill Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.249 2017/04/11 14:43:49 dhill Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
sc->sc_len = PFSYNC_MINPKT;
sc->sc_maxupdates = 128;
- sc->sc_imo.imo_membership = (struct in_multi **)mallocarray(
- IP_MIN_MEMBERSHIPS, sizeof(struct in_multi *), M_IPMOPTS,
+ sc->sc_imo.imo_membership = (struct in_multi **)malloc(
+ (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_IPMOPTS,
M_WAITOK | M_ZERO);
sc->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS;
-/* $OpenBSD: if_vxlan.c,v 1.58 2017/04/09 17:57:58 dhill Exp $ */
+/* $OpenBSD: if_vxlan.c,v 1.59 2017/04/11 14:43:49 dhill Exp $ */
/*
* Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org>
M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL)
return (ENOMEM);
- sc->sc_imo.imo_membership = mallocarray(
- IP_MIN_MEMBERSHIPS, sizeof(struct in_multi *), M_IPMOPTS,
+ sc->sc_imo.imo_membership = malloc(
+ (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_IPMOPTS,
M_WAITOK|M_ZERO);
sc->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS;
sc->sc_dstport = htons(VXLAN_PORT);
-/* $OpenBSD: ieee80211_input.c,v 1.190 2017/04/09 18:15:32 dhill Exp $ */
+/* $OpenBSD: ieee80211_input.c,v 1.191 2017/04/11 14:43:49 dhill Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
ba->ba_winstart = ssn;
ba->ba_winend = (ba->ba_winstart + ba->ba_winsize - 1) & 0xfff;
/* allocate and setup our reordering buffer */
- ba->ba_buf = mallocarray(IEEE80211_BA_MAX_WINSZ, sizeof(*ba->ba_buf),
+ ba->ba_buf = malloc(IEEE80211_BA_MAX_WINSZ * sizeof(*ba->ba_buf),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (ba->ba_buf == NULL)
goto refuse;
-/* $OpenBSD: ip_carp.c,v 1.306 2017/04/09 17:57:58 dhill Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.307 2017/04/11 14:43:49 dhill Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
#ifdef INET6
sc->sc_im6o.im6o_hlim = CARP_DFLTTL;
#endif /* INET6 */
- sc->sc_imo.imo_membership = (struct in_multi **)mallocarray(
- IP_MIN_MEMBERSHIPS, sizeof(struct in_multi *), M_IPMOPTS,
+ sc->sc_imo.imo_membership = (struct in_multi **)malloc(
+ (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_IPMOPTS,
M_WAITOK|M_ZERO);
sc->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS;
-/* $OpenBSD: ip_output.c,v 1.337 2017/04/09 17:57:58 dhill Exp $ */
+/* $OpenBSD: ip_output.c,v 1.338 2017/04/11 14:43:49 dhill Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
* allocate one and initialize to default values.
*/
imo = malloc(sizeof(*imo), M_IPMOPTS, M_WAITOK|M_ZERO);
- immp = (struct in_multi **)mallocarray(
- IP_MIN_MEMBERSHIPS, sizeof(*immp), M_IPMOPTS,
+ immp = (struct in_multi **)malloc(
+ (sizeof(*immp) * IP_MIN_MEMBERSHIPS), M_IPMOPTS,
M_WAITOK|M_ZERO);
*imop = imo;
imo->imo_ifidx = 0;
-/* $OpenBSD: ntfs_subr.c,v 1.49 2017/04/09 18:15:09 dhill Exp $ */
+/* $OpenBSD: ntfs_subr.c,v 1.50 2017/04/11 14:43:49 dhill Exp $ */
/* $NetBSD: ntfs_subr.c,v 1.4 2003/04/10 21:37:32 jdolecek Exp $ */
/*-
* XXX for now, just the first 256 entries are used anyway,
* so don't bother reading more
*/
- ntfs_toupper_tab = mallocarray(256 * 256, sizeof(wchar), M_NTFSRDATA,
+ ntfs_toupper_tab = malloc(256 * 256 * sizeof(wchar), M_NTFSRDATA,
M_WAITOK);
if ((error = VFS_VGET(mp, NTFS_UPCASEINO, &vp)))