From owner-svn-src-head@freebsd.org Sun Jan 14 00:17:26 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D84B8E629CC; Sun, 14 Jan 2018 00:17:26 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 7D4A17F78E; Sun, 14 Jan 2018 00:17:25 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with ESMTPA id aVzGeEES4Z8gBaVzHei9Fs; Sat, 13 Jan 2018 17:17:24 -0700 X-Authority-Analysis: v=2.2 cv=M/g9E24s c=1 sm=1 tr=0 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17 a=kj9zAlcOel0A:10 a=RgaUWeydRksA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=iobeIKzyZ5yR-PLec4sA:9 a=ofxHZX0y2bFOHBNL:21 a=bU5DJ2GvaiEwFHBX:21 a=4rh1IfhP2UJq8lIo:21 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id C4C3BEFCF; Sat, 13 Jan 2018 16:17:21 -0800 (PST) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id w0E0HKKY049186; Sat, 13 Jan 2018 16:17:20 -0800 (PST) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id w0E0HKS3049183; Sat, 13 Jan 2018 16:17:20 -0800 (PST) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201801140017.w0E0HKS3049183@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: "Pedro F. Giffuni" cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r327949 - in head/sys/dev: aacraid advansys ath beri/virtio bnxt bwn ciss cxgbe/crypto esp fb gpio if_ndis iwi kbd liquidio liquidio/base mpr mps mpt mrsas mxge netmap nvme pst ral rp s... In-Reply-To: Message from "Pedro F. Giffuni" of "Sat, 13 Jan 2018 22:30:31 +0000." <201801132230.w0DMUVmF081985@repo.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 13 Jan 2018 16:17:20 -0800 X-CMAE-Envelope: MS4wfNE12fHqDPXqqrKzMx1PkHg0dtQR/wgFa7i1ZTAtFGfajWcy7j2hrq/UgZbrbB8PzBNXY41Vb+5LugvLR/IOrpmKLdxJgsJwR6pdPuXBIMpAAsbTIBRL swEXl5sWUIgqJJTrJ4FPhvR4jbMqHNC+24iNdWR2CJyB0yznkSAEy/X2p5TC2xUXhn8jHd1bDoQUnrNZQzletRoPYYMGzMIp0zb3HPciu9OK8rDoC+aSJSSJ JNJPJ9Y4LHeNyWsINw9EGNsuAJnzyfYLdlBNhHvDK9PATPtuKONpxAtweIX9fkHe X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jan 2018 00:17:26 -0000 In message <201801132230.w0DMUVmF081985@repo.freebsd.org>, "Pedro F. Giffuni" w rites: > Author: pfg > Date: Sat Jan 13 22:30:30 2018 > New Revision: 327949 > URL: https://svnweb.freebsd.org/changeset/base/327949 > > Log: > dev: make some use of mallocarray(9). > > Focus on code where we are doing multiplications within malloc(9). None of > these is likely to overflow, however the change is still useful as some > static checkers can benefit from the allocation attributes we use for > mallocarray. > > This initial sweep only covers malloc(9) calls with M_NOWAIT. No good > reason but I started doing the changes before r327796 and at that time it > was convenient to make sure the sorrounding code could handle NULL values. > > Modified: > head/sys/dev/aacraid/aacraid.c > head/sys/dev/advansys/advansys.c > head/sys/dev/ath/if_ath_rx_edma.c > head/sys/dev/beri/virtio/virtio.c > head/sys/dev/bnxt/if_bnxt.c > head/sys/dev/bwn/if_bwn.c > head/sys/dev/bwn/if_bwn_phy_lp.c > head/sys/dev/ciss/ciss.c > head/sys/dev/cxgbe/crypto/t4_crypto.c > head/sys/dev/esp/ncr53c9x.c > head/sys/dev/fb/splash.c > head/sys/dev/gpio/gpiobus.c > head/sys/dev/if_ndis/if_ndis.c > head/sys/dev/iwi/if_iwi.c > head/sys/dev/kbd/kbd.c > head/sys/dev/liquidio/base/lio_request_manager.c > head/sys/dev/liquidio/lio_main.c > head/sys/dev/mpr/mpr.c > head/sys/dev/mpr/mpr_mapping.c > head/sys/dev/mps/mps.c > head/sys/dev/mps/mps_mapping.c > head/sys/dev/mpt/mpt_cam.c > head/sys/dev/mrsas/mrsas.c > head/sys/dev/mxge/if_mxge.c > head/sys/dev/netmap/if_ptnet.c > head/sys/dev/nvme/nvme_ns.c > head/sys/dev/pst/pst-iop.c > head/sys/dev/ral/rt2560.c > head/sys/dev/ral/rt2661.c > head/sys/dev/rp/rp.c > head/sys/dev/rp/rp_isa.c > head/sys/dev/rp/rp_pci.c > head/sys/dev/sound/midi/midi.c > head/sys/dev/sound/pci/hda/hdaa.c > head/sys/dev/syscons/fire/fire_saver.c > head/sys/dev/virtio/console/virtio_console.c > head/sys/dev/virtio/mmio/virtio_mmio.c > head/sys/dev/virtio/network/if_vtnet.c > head/sys/dev/virtio/pci/virtio_pci.c > head/sys/dev/vmware/vmxnet3/if_vmx.c > head/sys/dev/vnic/nicvf_queues.c > head/sys/dev/xen/blkback/blkback.c > head/sys/dev/xen/blkfront/blkfront.c > > Modified: head/sys/dev/mxge/if_mxge.c > ============================================================================= > = > --- head/sys/dev/mxge/if_mxge.c Sat Jan 13 21:39:46 2018 (r32794 > 8) > +++ head/sys/dev/mxge/if_mxge.c Sat Jan 13 22:30:30 2018 (r32794 > 9) > @@ -688,7 +688,7 @@ z_alloc(void *nil, u_int items, u_int size) > { > void *ptr; > > - ptr = malloc(items * size, M_TEMP, M_NOWAIT); > + ptr = mallocarray(items, size, M_TEMP, M_NOWAIT); > return ptr; > } > > @@ -4390,8 +4390,8 @@ mxge_alloc_slices(mxge_softc_t *sc) > sc->rx_ring_size = cmd.data0; > max_intr_slots = 2 * (sc->rx_ring_size / sizeof (mcp_dma_addr_t)); > > - bytes = sizeof (*sc->ss) * sc->num_slices; Hi Pedro, This broke the build. > - sc->ss = malloc(bytes, M_DEVBUF, M_NOWAIT | M_ZERO); > + sc->ss = mallocarray(sc->num_slices, sizeof(*sc->ss), M_DEVBUF, > + M_NOWAIT | M_ZERO); > if (sc->ss == NULL) > return (ENOMEM); > for (i = 0; i < sc->num_slices; i++) { > @@ -4563,8 +4563,8 @@ mxge_add_msix_irqs(mxge_softc_t *sc) > err = ENOSPC; > goto abort_with_msix; > } > - bytes = sizeof (*sc->msix_irq_res) * sc->num_slices; > - sc->msix_irq_res = malloc(bytes, M_DEVBUF, M_NOWAIT|M_ZERO); > + sc->msix_irq_res = mallocarray(sc->num_slices, > + sizeof(*sc->msix_irq_res), M_DEVBUF, M_NOWAIT|M_ZERO); > if (sc->msix_irq_res == NULL) { > err = ENOMEM; > goto abort_with_msix; > @@ -4583,8 +4583,8 @@ mxge_add_msix_irqs(mxge_softc_t *sc) > } > } > > - bytes = sizeof (*sc->msix_ih) * sc->num_slices; ===> mxge/mxge_rss_ethp_z8e (all) --- all_subdir_mxge/mxge --- /opt/src/svn-current/sys/dev/mxge/if_mxge.c:4538:9: error: unused variable 'bytes' [-Werror,-Wunused-variable] size_t bytes; ^ 1 error generated. *** [if_mxge.o] Error code 1 > - sc->msix_ih = malloc(bytes, M_DEVBUF, M_NOWAIT|M_ZERO); > + sc->msix_ih = mallocarray(sc->num_slices, sizeof(*sc->msix_ih), > + M_DEVBUF, M_NOWAIT|M_ZERO); > > for (i = 0; i < sc->num_slices; i++) { > err = bus_setup_intr(sc->dev, sc->msix_irq_res[i], > -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few.