From nobody Fri Mar 11 10:57:45 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D48661A1B720; Fri, 11 Mar 2022 10:57:54 +0000 (UTC) (envelope-from mpp302@gmail.com) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KFNFF5nrxz4q0m; Fri, 11 Mar 2022 10:57:53 +0000 (UTC) (envelope-from mpp302@gmail.com) Received: by mail-ed1-f52.google.com with SMTP id x5so10390864edd.11; Fri, 11 Mar 2022 02:57:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=WJQMAuRltaimJ3rZkSyvbhVhkgfTb3ZfZnk3qTtqOgY=; b=J3C4Qtjs9+1AIUhI0OR/QC9Qd9Hk8oYuETeK4tC2xrx1u60x59ywLkZhIePXg02UcC hHHUGR8VX2gaE9NsHbbNVA/3Nih75lnL4DZenB8uiavDgscMlfL2N6VerE8hVRPCvcqa SCTsmaH3o7ITJJl5F5WUtzWdP92c9GUSH4wnqMuSPWtocTH7sMg9cYcEXpQa9P3aFy8O HHo8ZlSmXAl95tAkFWi8s8SKhpNoSPEjl0q2XhP3T4u73WZRTwhdT+p3JGRLftOyAQtO nUZGK5jY5xje0Zfq6PKAoj6x+oz5e39UCbX+tlebPJJwzRguzUU5z0D6/bT3EnWmBpzj uM+g== X-Gm-Message-State: AOAM530yQqoA8b3Bsfh5j4B1HOnIP1lPby0s1Ez36jGiEv7ubITAri7N K8lO01mPzemuxcA0XsZxjzKOyP8xXhE= X-Google-Smtp-Source: ABdhPJwen3Sqd4FZyA/0DlFwjhA3uaO9jIW6DH6PmEZU0RDm1iZwfW7FeJa8hLX5jJ3fl1oS9p/tDw== X-Received: by 2002:a05:6402:1941:b0:413:2b80:b245 with SMTP id f1-20020a056402194100b004132b80b245mr8416759edz.252.1646996266701; Fri, 11 Mar 2022 02:57:46 -0800 (PST) Received: from ?IPV6:2a02:8109:9880:1d70:5e5f:67ff:fef4:ffd8? ([2a02:8109:9880:1d70:5e5f:67ff:fef4:ffd8]) by smtp.gmail.com with ESMTPSA id da19-20020a056402177300b00413583e0996sm3102885edb.14.2022.03.11.02.57.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Mar 2022 02:57:46 -0800 (PST) Message-ID: <4eaba9f4-7cd6-5af3-d745-97932501a2fc@FreeBSD.org> Date: Fri, 11 Mar 2022 11:57:45 +0100 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: git: 419822b372f5 - main - libgeom(3): Use calloc instead of malloc and bzero. Content-Language: en-US To: Hans Petter Selasky , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202203110942.22B9guNt032463@gitrepo.freebsd.org> From: Mateusz Piotrowski <0mp@FreeBSD.org> In-Reply-To: <202203110942.22B9guNt032463@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4KFNFF5nrxz4q0m X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of mpp302@gmail.com designates 209.85.208.52 as permitted sender) smtp.mailfrom=mpp302@gmail.com X-Spamd-Result: default: False [-2.75 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[FreeBSD.org]; NEURAL_HAM_LONG(-0.89)[-0.888]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; NEURAL_HAM_SHORT(-0.86)[-0.859]; RCVD_IN_DNSWL_NONE(0.00)[209.85.208.52:from]; MLMMJ_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; FORGED_SENDER(0.30)[0mp@FreeBSD.org,mpp302@gmail.com]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.208.52:from]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[0mp@FreeBSD.org,mpp302@gmail.com]; FREEMAIL_ENVFROM(0.00)[gmail.com] X-ThisMailContainsUnwantedMimeParts: N 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? Best, Mateusz On 11/03/2022 10:42, Hans Petter Selasky wrote: > The branch main has been updated by hselasky: > > URL: https://cgit.FreeBSD.org/src/commit/?id=419822b372f543b22d7fb04eae0dffacf058feb6 > > commit 419822b372f543b22d7fb04eae0dffacf058feb6 > Author: Hans Petter Selasky > AuthorDate: 2022-03-10 09:16:27 +0000 > Commit: Hans Petter Selasky > CommitDate: 2022-03-11 09:38:16 +0000 > > libgeom(3): Use calloc instead of malloc and bzero. > > Pull Request: https://github.com/freebsd/freebsd-src/pull/546 > MFC after: 1 week > Sponsored by: NVIDIA Networking > --- > lib/geom/virstor/geom_virstor.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/lib/geom/virstor/geom_virstor.c b/lib/geom/virstor/geom_virstor.c > index 25ebdebbe7eb..bd8da7337a55 100644 > --- a/lib/geom/virstor/geom_virstor.c > +++ b/lib/geom/virstor/geom_virstor.c > @@ -406,10 +406,9 @@ virstor_label(struct gctl_req *req) > } else > strlcpy(md.provider, name, sizeof(md.provider)); > } > - sect = malloc(ssize); > + sect = calloc(ssize, sizeof(unsigned char)); > if (sect == NULL) > err(1, "Cannot allocate sector of %zu bytes", ssize); > - bzero(sect, ssize); > virstor_metadata_encode(&md, sect); > error = g_metadata_store(name, sect, ssize); > free(sect); >