Re: git: 419822b372f5 - main - libgeom(3): Use calloc instead of malloc and bzero.
- In reply to: Warner Losh : "Re: git: 419822b372f5 - main - libgeom(3): Use calloc instead of malloc and bzero."
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 11 Mar 2022 15:40:15 UTC
On 11/03/2022 15:15, Warner Losh wrote: > > > On Fri, Mar 11, 2022, 4:10 AM Hans Petter Selasky <hps@selasky.org> wrote: > > On 3/11/22 11:57, Mateusz Piotrowski wrote: > > Hi, > > > > I grepped out tree and there are many other places, which could be > > converted to using calloc. Is there anything to watch out for when > > converting malloc and memset call pairs to calloc? > > > > If you have a tool for it combined with a review, should be pretty > straight forward. > > > You likely can use coccinelle to find these. It works better than grep. Everything is probably better than grep in this case. I actually used weggli to find those malloc/memset uses. I was actually thinking if something about the calloc implementation could bite us if we just change all malloc/memset occurances to calloc. Something similar to what is described in this article for example: https://willnewton.name/2013/06/17/calloc-versus-malloc-and-memset/ Best, Mateusz Piotrowski