From owner-svn-src-all@freebsd.org Mon Jan 9 01:02:17 2017 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 A5EB7CA5144; Mon, 9 Jan 2017 01:02:17 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5D9331EE3; Mon, 9 Jan 2017 01:02:17 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v0912GsB084894; Mon, 9 Jan 2017 01:02:16 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v0912Gjt084893; Mon, 9 Jan 2017 01:02:16 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201701090102.v0912Gjt084893@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 9 Jan 2017 01:02:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r311717 - stable/11/lib/libc/net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Mon, 09 Jan 2017 01:02:17 -0000 Author: ngie Date: Mon Jan 9 01:02:16 2017 New Revision: 311717 URL: https://svnweb.freebsd.org/changeset/base/311717 Log: MFC r310984,r311102: r310984: Use calloc instead of malloc + memset(.., 0, ..) r311102 (by pfg): Cleanup inelegant calloc(3) introduced in r310984. Modified: stable/11/lib/libc/net/getaddrinfo.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/net/getaddrinfo.c ============================================================================== --- stable/11/lib/libc/net/getaddrinfo.c Mon Jan 9 01:00:20 2017 (r311716) +++ stable/11/lib/libc/net/getaddrinfo.c Mon Jan 9 01:02:16 2017 (r311717) @@ -691,9 +691,8 @@ reorder(struct addrinfo *sentinel) return(n); /* allocate a temporary array for sort and initialization of it. */ - if ((aio = malloc(sizeof(*aio) * n)) == NULL) + if ((aio = calloc(n, sizeof(*aio))) == NULL) return(n); /* give up reordering */ - memset(aio, 0, sizeof(*aio) * n); /* retrieve address selection policy from the kernel */ TAILQ_INIT(&policyhead); @@ -1449,9 +1448,8 @@ copy_ai(const struct addrinfo *pai) size_t l; l = sizeof(*ai) + pai->ai_addrlen; - if ((ai = (struct addrinfo *)malloc(l)) == NULL) + if ((ai = calloc(1, l)) == NULL) return NULL; - memset(ai, 0, l); memcpy(ai, pai, sizeof(*ai)); ai->ai_addr = (struct sockaddr *)(void *)(ai + 1); memcpy(ai->ai_addr, pai->ai_addr, pai->ai_addrlen); @@ -1874,8 +1872,7 @@ addrinfo_unmarshal_func(char *buffer, si size = new_ai.ai_addrlen + sizeof(struct addrinfo) + _ALIGNBYTES; - sentinel = (struct addrinfo *)malloc(size); - memset(sentinel, 0, size); + sentinel = calloc(1, size); memcpy(sentinel, &new_ai, sizeof(struct addrinfo)); sentinel->ai_addr = (struct sockaddr *)_ALIGN((char *)sentinel + @@ -1888,8 +1885,7 @@ addrinfo_unmarshal_func(char *buffer, si memcpy(&size, p, sizeof(size_t)); p += sizeof(size_t); - sentinel->ai_canonname = (char *)malloc(size + 1); - memset(sentinel->ai_canonname, 0, size + 1); + sentinel->ai_canonname = calloc(1, size + 1); memcpy(sentinel->ai_canonname, p, size); p += size;