mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
Partially revert previous mallocarray conversions that contain
constants. The consensus is that if both operands are constant, we don't need mallocarray. Reminded by tedu@ ok deraadt@
This commit is contained in:
parent
9b02d1d5b2
commit
265a1ec57e
@ -1,4 +1,4 @@
|
||||
/* $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
|
||||
@ -1277,7 +1277,7 @@ aac_init(struct aac_softc *sc)
|
||||
|
||||
/* 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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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 $ */
|
||||
|
||||
/*
|
||||
@ -144,7 +144,7 @@ adw_alloc_carriers(ADW_SOFTC *sc)
|
||||
* 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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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 $ */
|
||||
|
||||
/*-
|
||||
@ -2973,7 +2973,7 @@ ath_getchannels(struct ath_softc *sc, HAL_BOOL outdoor, HAL_BOOL xchanmode)
|
||||
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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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 $ */
|
||||
|
||||
/*-
|
||||
@ -1097,7 +1097,7 @@ azalia_init_rirb(azalia_t *az, int resuming)
|
||||
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",
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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
|
||||
@ -360,7 +360,7 @@ dc_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||
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");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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
|
||||
*
|
||||
@ -1561,7 +1561,7 @@ nep_up(struct nep_softc *sc)
|
||||
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];
|
||||
@ -1592,7 +1592,7 @@ nep_up(struct nep_softc *sc)
|
||||
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];
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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 $ */
|
||||
|
||||
/*
|
||||
@ -2184,14 +2184,14 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg,
|
||||
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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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 $ */
|
||||
|
||||
/*
|
||||
@ -222,10 +222,10 @@ wsemul_vt100_attach(int console, const struct wsscreen_descr *type,
|
||||
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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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 $ */
|
||||
|
||||
/*
|
||||
@ -109,7 +109,7 @@ wsevent_init(struct wseventvar *ev)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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
|
||||
@ -316,8 +316,8 @@ pfsync_clone_create(struct if_clone *ifc, int unit)
|
||||
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;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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>
|
||||
@ -129,8 +129,8 @@ vxlan_clone_create(struct if_clone *ifc, int unit)
|
||||
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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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
|
||||
@ -2566,7 +2566,7 @@ ieee80211_recv_addba_req(struct ieee80211com *ic, struct mbuf *m,
|
||||
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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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.
|
||||
@ -795,8 +795,8 @@ carp_clone_create(struct if_clone *ifc, int unit)
|
||||
#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;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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 $ */
|
||||
|
||||
/*
|
||||
@ -1344,8 +1344,8 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m,
|
||||
* 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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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 $ */
|
||||
|
||||
/*-
|
||||
@ -1754,7 +1754,7 @@ ntfs_toupper_use(struct mount *mp, struct ntfsmount *ntmp, struct proc *p)
|
||||
* 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)))
|
||||
|
Loading…
Reference in New Issue
Block a user