From owner-svn-src-all@freebsd.org Sat Dec 31 21:55:20 2016 Return-Path: Delivered-To: svn-src-all@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 CE466C99275; Sat, 31 Dec 2016 21:55:20 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9B2B91BF2; Sat, 31 Dec 2016 21:55:20 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pg0-x241.google.com with SMTP id b1so26068446pgc.1; Sat, 31 Dec 2016 13:55:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:mime-version:from:in-reply-to:date:cc:message-id:references :to; bh=wsWAGr4eBsz7wc2bE2N2dknFL63WapGdi5S6yr9O+o0=; b=S5nPI5uyH3NsscTvdsPjO0TP2s7t7KZqqKmKpwFeXOYWdhINPSedWDZK6rNKPMiZqM zXAly3JW6w1G+rFUuGTWD8hsK7P2V+t7I1zoYcYb1M43xdVf0jTBS+56BLldEo+WG0dM 77sQzZEmUhpKmO/PYIYOB/u61wmD1jL/ZDc2WkkufyKyV5Uyypcf50EaCCqTfJo79KW+ 0YcA5s1nltjLe0molgKHitwTOBZQEgUQJtbnzl+ZrnD2bBwTyTTpf80OescoziByxcoa jStpJ+QtIP75aPWrIXdRuPWVTv91NUJWgkaM8nVl5E6HEJLGUC5NuC8Yx+ws2XIEV256 Q72g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :message-id:references:to; bh=wsWAGr4eBsz7wc2bE2N2dknFL63WapGdi5S6yr9O+o0=; b=PLxFLX+DSpj96efZfLTr8KjkJZZXctIYwmk+s6mEPetio1oVh6jRX8VV2Ol6L+ABDw DmHcsAtAO2v+5RlODCNCb46CVPBNtsV43wxXv2ObRY1U0PgcRMFr3xb42apP0a9aDlM/ RS785b7woLEoNYPaQywGxnlMcd8E7KTmKUSlXrNJ2bwKCU/G5HktygPu/xsr9f/vC/mv 1R+mX0n+cc2tiwo9MJZMIyvjTrrGHpZbqlEl/JzIbeMRMcSPISx/jaJNjGXojKGr/BeF a3a5GkodUVLQJXAZAcyuiDqI1WK0y3FJj/62z4dQk6KlGzyaTlcaaC/3kL6kOYNR4P2n LRtg== X-Gm-Message-State: AIkVDXKDw8AlUsYmn+O4FpVcIUtNNgs6h+lzJs2LqVjyhI+n7K8Dw4vIDcx6Kc/gKtv/XQ== X-Received: by 10.98.36.134 with SMTP id k6mr40691007pfk.3.1483221319507; Sat, 31 Dec 2016 13:55:19 -0800 (PST) Received: from [192.168.20.12] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id 65sm121744263pfn.12.2016.12.31.13.55.18 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 Dec 2016 13:55:18 -0800 (PST) Subject: Re: svn commit: r310984 - head/lib/libc/net Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_867E2280-4CAE-477F-8AD1-C825FC4B1A12"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Pgp-Agent: GPGMail From: "Ngie Cooper (yaneurabeya)" In-Reply-To: <7914bb49-6bef-6bbd-5574-ceb29f318c01@FreeBSD.org> Date: Sat, 31 Dec 2016 13:55:18 -0800 Cc: Ngie Cooper , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-Id: <371A5B4E-0766-49F4-9115-13598B3E74FF@gmail.com> References: <201612312100.uBVL09RR092355@repo.freebsd.org> <7914bb49-6bef-6bbd-5574-ceb29f318c01@FreeBSD.org> To: Pedro Giffuni X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Dec 2016 21:55:20 -0000 --Apple-Mail=_867E2280-4CAE-477F-8AD1-C825FC4B1A12 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Dec 31, 2016, at 13:49, Pedro Giffuni wrote: >=20 >=20 >=20 > On 12/31/16 16:00, Ngie Cooper wrote: >> Author: ngie >> Date: Sat Dec 31 21:00:08 2016 >> New Revision: 310984 >> URL: https://svnweb.freebsd.org/changeset/base/310984 >>=20 >> Log: >> Use calloc instead of malloc + memset(.., 0, ..) >>=20 >> MFC after: 1 week >>=20 >> Modified: >> head/lib/libc/net/getaddrinfo.c >>=20 >> Modified: head/lib/libc/net/getaddrinfo.c >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/lib/libc/net/getaddrinfo.c Sat Dec 31 19:59:31 2016 = (r310983) >> +++ head/lib/libc/net/getaddrinfo.c Sat Dec 31 21:00:08 2016 = (r310984) >> @@ -691,9 +691,8 @@ reorder(struct addrinfo *sentinel) >> return(n); >>=20 >> /* allocate a temporary array for sort and initialization of it. = */ >> - if ((aio =3D malloc(sizeof(*aio) * n)) =3D=3D NULL) >> + if ((aio =3D calloc(1, sizeof(*aio) * n)) =3D=3D NULL) >> return(n); /* give up reordering */ >=20 > This should be calloc(n, sizeof(*aio))) >=20 > FWIW, the other cases are not very useful. > Generally, replacing any malloc(x) with a calloc(1, x) doesn't bring = any advantage as it won't catch any overflow. Yeah, that would have been better. The goal was to reduce complexity. I found some memory leaks with = valgrind with bsnmp* last night involving getaddrinfo that I=E2=80=99m = trying to chase down, and I noticed these while =E2=80=9Cin the = neighborhood=E2=80=9D. Thanks! -Ngie --Apple-Mail=_867E2280-4CAE-477F-8AD1-C825FC4B1A12 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJYaClGAAoJEPWDqSZpMIYV1E8QAKvomvKcUWo7fD1sF5t4YU7N jX6jwiOgzgr9y1Ur34xETJTaHaFCjV5+xa5mQCdKQv4E2LPbwjUfH1qHH9P0DDFX KgP34vgYiahrBJcUwpeYhNPXhl+i2gLQ1Tnu2G8gbOzGnf0nWKTgoZ56c0ZAE3zW OEdn4AU9KBeeNliuEc8j54Z6HxGq8biqm6ymS6ZHHGBRjlIHdT5FFIXscIKQW1eD 3H6pX+8ZNfu+OkWQMJbT2lkMswJRBFYC8hYrqUqZbk8etaj9gABaZ2szIyNbTq+x LYtK3qEirXyfcHEYmlrzBuItI73J3hymyGyWRog3M7Pfw2jZ151ACmwtDWcbT4er tBoooYqHRSLB67GB2MI1tWXYDQUnBnuYgm4oKxwxyGo5zHp+UdLWGE9ChPx5LjwF /hQeUF43EpUnT21Pgq/qWuFNHyOd+TeOT0kgch/pvkUD8L5/Q0/jYpexDvcKmJQr ndxYov/KY4IVkmCwiih0POVd44VaPqTUlIal7POIGWgfR9HK/izSX3Lx+5GnY5Qr 7gepw4gxLROuDEK+r834XeNY8zcfV7eGie10P6enB0zfZ3Qh2a9YNSZZSfZZkNaZ KB0DUDqWtBnBaKRsI8tU6tuXNZTlpYP1AN/PklBzj6gCnyFlHAEU96tAY+KBdj4K 3C75vbRrfti5cHoIBoRi =IcFw -----END PGP SIGNATURE----- --Apple-Mail=_867E2280-4CAE-477F-8AD1-C825FC4B1A12--