From nobody Wed Dec 01 08:20:29 2021 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 AECDD18B36F1; Wed, 1 Dec 2021 08:20:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J3sTn3BqCz3Gws; Wed, 1 Dec 2021 08:20:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4DADE264A8; Wed, 1 Dec 2021 08:20:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B18KTBh015170; Wed, 1 Dec 2021 08:20:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B18KTUN015169; Wed, 1 Dec 2021 08:20:29 GMT (envelope-from git) Date: Wed, 1 Dec 2021 08:20:29 GMT Message-Id: <202112010820.1B18KTUN015169@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: a01b8859cbde - main - sctp: cleanup, no functional change intended. 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a01b8859cbde9f2ded7b58a024d8fb46ada596bb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638346829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YLoyNw7hG+JRyIRmAwVIHs6i4+AJJQzYeWQCVBgLnjg=; b=U4nD+5WUjl+KbGwVxRQ8U+A3YDhcD7bawZqHivxx3e5U4TaeCIfHiebx6tOQ/5uPIPamgN FLWOtbEZUz70cNM00l+ojkvdacsFdcQLvnncoY0rCBgwpIa5mPEgx0V+st0QSY+z7911fM nUuQQZxekrNGLqSXkG+phMUYnihTJ05/udLkWeo9BYY//WyIzoNSYIPpJCEbXCpwNAgb5h 1tmuMARmwKZU2+iX5NMg9ISq7zp2Xqlvp9idI8jV2nZCjhQbx54JMhbwevIhtg2I0xhYY3 +ZZt/+0SOxf5vSoUMzHE1KTlCMWWULTHBld+R1C/X04PAFt3GWaQF+iPsyLZuQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638346829; a=rsa-sha256; cv=none; b=FiVSGFL3OUv5ETT4T+s+kQB0G/ttG7P2NLOWCLPBGYGzMdd58S9DnlEDXQMJea6Rn6TXe7 spr1cGiju4Trv/akXmvhQCptgCdoWmPwgwaUvnt7ILdiF69Tlf4Q60iqBzzINyOOe/B68Q PxbKbW1Dh+wD/jKlkInaMHRl2IQBgBVQ49T0tnarOC58a6Tr0+NmQAsyZUDEZMwUpdB4/p HqTXRNySb8n8EX+xDuvqipMrqrOCH8TZC+/pIH5EnCTRrcvBvNanz20tmb5RfbNxSOn79X KzcYFSADTsV0E1oGO4UvE6LZdASCTyyu9zChso1RYlPVMKcG+kBXETZXhYkPiw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=a01b8859cbde9f2ded7b58a024d8fb46ada596bb commit a01b8859cbde9f2ded7b58a024d8fb46ada596bb Author: Michael Tuexen AuthorDate: 2021-12-01 08:19:40 +0000 Commit: Michael Tuexen CommitDate: 2021-12-01 08:19:40 +0000 sctp: cleanup, no functional change intended. MFC after: 1 week --- sys/netinet/sctp_usrreq.c | 59 ++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index b2d23bffb9fd..dae35c566d4e 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -1228,7 +1228,7 @@ sctp_fill_up_addresses(struct sctp_inpcb *inp, size_t limit, struct sockaddr *addr) { - size_t size = 0; + size_t size; SCTP_IPI_ADDR_RLOCK(); /* fill up addresses for the endpoint's default vrf */ @@ -1238,17 +1238,17 @@ sctp_fill_up_addresses(struct sctp_inpcb *inp, return (size); } -static int -sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) +static size_t +sctp_max_size_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) { - int cnt = 0; - struct sctp_vrf *vrf = NULL; + struct sctp_vrf *vrf; + size_t size; /* - * In both sub-set bound an bound_all cases we return the MAXIMUM - * number of addresses that you COULD get. In reality the sub-set - * bound may have an exclusion list for a given TCB OR in the - * bound-all case a TCB may NOT include the loopback or other + * In both sub-set bound an bound_all cases we return the size of + * the maximum number of addresses that you could get. In reality + * the sub-set bound may have an exclusion list for a given TCB or + * in the bound-all case a TCB may NOT include the loopback or other * addresses as well. */ SCTP_IPI_ADDR_LOCK_ASSERT(); @@ -1256,6 +1256,7 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) if (vrf == NULL) { return (0); } + size = 0; if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { struct sctp_ifn *sctp_ifn; struct sctp_ifa *sctp_ifa; @@ -1268,17 +1269,17 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) case AF_INET: #ifdef INET6 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #endif break; #endif #ifdef INET6 case AF_INET6: - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); break; #endif default: @@ -1295,17 +1296,17 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) case AF_INET: #ifdef INET6 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #endif break; #endif #ifdef INET6 case AF_INET6: - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); break; #endif default: @@ -1313,19 +1314,19 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) } } } - return (cnt); + return (size); } -static int -sctp_count_max_addresses(struct sctp_inpcb *inp) +static size_t +sctp_max_size_addresses(struct sctp_inpcb *inp) { - int cnt = 0; + size_t size; SCTP_IPI_ADDR_RLOCK(); - /* count addresses for the endpoint's default VRF */ - cnt = sctp_count_max_addresses_vrf(inp, inp->def_vrf_id); + /* Maximum size of all addresses for the endpoint's default VRF */ + size = sctp_max_size_addresses_vrf(inp, inp->def_vrf_id); SCTP_IPI_ADDR_RUNLOCK(); - return (cnt); + return (size); } static int @@ -2140,7 +2141,7 @@ flags_out: SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize); SCTP_INP_RLOCK(inp); - *value = sctp_count_max_addresses(inp); + *value = (uint32_t)sctp_max_size_addresses(inp); SCTP_INP_RUNLOCK(inp); *optsize = sizeof(uint32_t); break; @@ -2148,14 +2149,14 @@ flags_out: case SCTP_GET_REMOTE_ADDR_SIZE: { uint32_t *value; - size_t size; struct sctp_nets *net; + size_t size; SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize); /* FIXME MT: change to sctp_assoc_value? */ SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t)*value); - if (stcb) { + if (stcb != NULL) { size = 0; /* Count the sizes */ TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { @@ -2205,7 +2206,7 @@ flags_out: SCTP_CHECK_AND_CAST(saddr, optval, struct sctp_getaddresses, *optsize); SCTP_FIND_STCB(inp, stcb, saddr->sget_assoc_id); - if (stcb) { + if (stcb != NULL) { left = *optsize - offsetof(struct sctp_getaddresses, addr); *optsize = offsetof(struct sctp_getaddresses, addr); addr = &saddr->addr[0].sa; @@ -2276,7 +2277,7 @@ flags_out: limit = *optsize - offsetof(struct sctp_getaddresses, addr); actual = sctp_fill_up_addresses(inp, stcb, limit, &saddr->addr[0].sa); - if (stcb) { + if (stcb != NULL) { SCTP_TCB_UNLOCK(stcb); } *optsize = offsetof(struct sctp_getaddresses, addr) + actual;