Re: mallocarray() in sys/dev, first pass

2014-07-13 Thread patrick keshishian
On Sun, Jul 13, 2014 at 11:29:22AM -0600, dera...@cvs.openbsd.org wrote: > This is the first pass of mallocarray() in sys/dev. Please proofread. [...] > === > RCS file: /cvs/src/sys/dev/softraid.c,v > retrieving revision 1.334 > diff

Re: mallocarray() in sys/dev, first pass

2014-07-13 Thread Theo de Raadt
> > Index: ic/malo.c > > - ring->data = malloc(count * sizeof (struct malo_rx_data), M_DEVBUF, > > - M_NOWAIT); > > + ring->data = mallocarray(count, sizeof (struct malo_rx_data), > > + M_DEVBUF, M_NOWAIT); > > Might as well s/sizeof (/sizeof(/ while you're here. And fix the inter

Re: mallocarray() in sys/dev, first pass

2014-07-13 Thread Jean-Philippe Ouellet
And some cosmetic things: > Index: ic/malo.c > - ring->data = malloc(count * sizeof (struct malo_rx_data), M_DEVBUF, > - M_NOWAIT); > + ring->data = mallocarray(count, sizeof (struct malo_rx_data), > + M_DEVBUF, M_NOWAIT); Might as well s/sizeof (/sizeof(/ while you're her

Re: mallocarray() in sys/dev, first pass

2014-07-13 Thread Jean-Philippe Ouellet
On Sun, Jul 13, 2014 at 11:29:22AM -0600, dera...@cvs.openbsd.org wrote: > - ldp = malloc(sizeof(*ldp) + (k-1), M_DEVBUF, M_NOWAIT); > + ldp = mallocarray(k-1, sizeof(*ldp), M_DEVBUF, M_NOWAIT); Are you sure k-1 can never be small enough such that a*b is less than a+b?

mallocarray() in sys/dev, first pass

2014-07-13 Thread deraadt
This is the first pass of mallocarray() in sys/dev. Please proofread. Index: rd.c === RCS file: /cvs/src/sys/dev/rd.c,v retrieving revision 1.7 diff -u -p -u -r1.7 rd.c --- rd.c12 Jul 2014 18:48:51 - 1.7 +++ rd.c