Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Mar 2022 16:40:15 +0100
From:      Mateusz Piotrowski <0mp@FreeBSD.org>
To:        Warner Losh <imp@bsdimp.com>, Hans Petter Selasky <hps@selasky.org>
Cc:        src-committers <src-committers@freebsd.org>, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: 419822b372f5 - main - libgeom(3): Use calloc instead of malloc and bzero.
Message-ID:  <5c05a9a5-2160-48e7-6e0f-2e7784b7e3aa@FreeBSD.org>
In-Reply-To: <CANCZdfrm4n9ML==p_Uwb0PAneY6jgUc8gA_hDgoommmCB=8C3g@mail.gmail.com>
References:  <202203110942.22B9guNt032463@gitrepo.freebsd.org> <4eaba9f4-7cd6-5af3-d745-97932501a2fc@FreeBSD.org> <a55f8a81-7897-6f6d-68fe-de41a733dce2@selasky.org> <CANCZdfrm4n9ML==p_Uwb0PAneY6jgUc8gA_hDgoommmCB=8C3g@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------Lowk4kw4691zA9zNqjgW2F3W
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

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

--------------Lowk4kw4691zA9zNqjgW2F3W
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 11/03/2022 15:15, Warner Losh wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CANCZdfrm4n9ML==p_Uwb0PAneY6jgUc8gA_hDgoommmCB=8C3g@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="auto">
        <div><br>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">On Fri, Mar 11, 2022, 4:10
              AM Hans Petter Selasky &lt;<a
                href="mailto:hps@selasky.org" moz-do-not-send="true"
                class="moz-txt-link-freetext">hps@selasky.org</a>&gt;
              wrote:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">On
              3/11/22 11:57, Mateusz Piotrowski wrote:<br>
              &gt; Hi,<br>
              &gt; <br>
              &gt; I grepped out tree and there are many other places,
              which could be <br>
              &gt; converted to using calloc. Is there anything to watch
              out for when <br>
              &gt; converting malloc and memset call pairs to calloc?<br>
              &gt; <br>
              <br>
              If you have a tool for it combined with a review, should
              be pretty <br>
              straight forward.<br>
            </blockquote>
          </div>
        </div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">You likely can use coccinelle to find these. It
          works better than grep.</div>
      </div>
    </blockquote>
    <p>Everything is probably better than grep in this case. I actually
      used weggli to find those malloc/memset uses.</p>
    <p>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:<br>
    </p>
    <p><a class="moz-txt-link-freetext" href="https://willnewton.name/2013/06/17/calloc-versus-malloc-and-memset/">https://willnewton.name/2013/06/17/calloc-versus-malloc-and-memset/</a></p>;
    <p><br>
    </p>
    <p>Best,</p>
    <p>Mateusz Piotrowski<br>
    </p>
  </body>
</html>

--------------Lowk4kw4691zA9zNqjgW2F3W--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5c05a9a5-2160-48e7-6e0f-2e7784b7e3aa>