Module Name: src Committed By: ozaki-r Date: Fri Nov 4 09:04:27 UTC 2022
Modified Files: src/sys/netinet: in_pcb.c src/sys/netinet6: in6_pcb.c Log Message: inpcb: get rid of parentheses for return value To generate a diff of this commit: cvs rdiff -u -r1.199 -r1.200 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.176 -r1.177 src/sys/netinet6/in6_pcb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet/in_pcb.c diff -u src/sys/netinet/in_pcb.c:1.199 src/sys/netinet/in_pcb.c:1.200 --- src/sys/netinet/in_pcb.c:1.199 Fri Nov 4 09:03:56 2022 +++ src/sys/netinet/in_pcb.c Fri Nov 4 09:04:27 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in_pcb.c,v 1.199 2022/11/04 09:03:56 ozaki-r Exp $ */ +/* $NetBSD: in_pcb.c,v 1.200 2022/11/04 09:04:27 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -93,7 +93,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.199 2022/11/04 09:03:56 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.200 2022/11/04 09:04:27 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -211,7 +211,7 @@ inpcb_create(struct socket *so, void *v) inp = pool_cache_get(in4pcb_pool_cache, PR_NOWAIT); #endif if (inp == NULL) - return (ENOBUFS); + return ENOBUFS; if (soaf(so) == AF_INET) memset(inp, 0, sizeof(struct in4pcb)); #ifdef INET6 @@ -260,7 +260,7 @@ inpcb_create(struct socket *so, void *v) inp_lhash); inpcb_set_state(inp, INP_ATTACHED); splx(s); - return (0); + return 0; } static int @@ -291,7 +291,7 @@ inpcb_set_port(struct sockaddr_in *sin, error = kauth_authorize_network(cred, KAUTH_NETWORK_BIND, req, so, sin, NULL); if (error) - return (EACCES); + return EACCES; /* * Use RFC6056 randomized port selection @@ -306,7 +306,7 @@ inpcb_set_port(struct sockaddr_in *sin, inp->inp_lport = lport; inpcb_set_state(inp, INP_BOUND); - return (0); + return 0; } int @@ -318,7 +318,7 @@ inpcb_bindableaddr(const struct inpcb *i int s; if (sin->sin_family != AF_INET) - return (EAFNOSUPPORT); + return EAFNOSUPPORT; s = pserialize_read_enter(); if (IN_MULTICAST(sin->sin_addr.s_addr)) { @@ -382,7 +382,7 @@ inpcb_bind_port(struct inpcb *inp, struc if (sin->sin_port == 0) { error = inpcb_set_port(sin, inp, cred); if (error) - return (error); + return error; } else { struct inpcb *t; vestigial_inpcb_t vestige; @@ -405,13 +405,13 @@ inpcb_bind_port(struct inpcb *inp, struc error = kauth_authorize_network(cred, KAUTH_NETWORK_BIND, req, so, sin, NULL); if (error) - return (EACCES); + return EACCES; #ifdef INET6 in6_in_2_v4mapin6(&sin->sin_addr, &mapped); t6 = in6pcb_lookup_local(table, &mapped, sin->sin_port, wild, &vestige); if (t6 && (reuseport & t6->inp_socket->so_options) == 0) - return (EADDRINUSE); + return EADDRINUSE; if (!t6 && vestige.valid) { if (!!reuseport != !!vestige.reuse_port) { return EADDRINUSE; @@ -432,7 +432,7 @@ inpcb_bind_port(struct inpcb *inp, struc !in_nullhost(in4p_laddr(t)) || (t->inp_socket->so_options & SO_REUSEPORT) == 0) && (so->so_uidinfo->ui_uid != t->inp_socket->so_uidinfo->ui_uid)) { - return (EADDRINUSE); + return EADDRINUSE; } if (!t && vestige.valid) { if ((!in_nullhost(sin->sin_addr) @@ -445,7 +445,7 @@ inpcb_bind_port(struct inpcb *inp, struc } t = inpcb_lookup_local(table, sin->sin_addr, sin->sin_port, wild, &vestige); if (t && (reuseport & t->inp_socket->so_options) == 0) - return (EADDRINUSE); + return EADDRINUSE; if (!t && vestige.valid && !(reuseport && vestige.reuse_port)) @@ -459,7 +459,7 @@ inpcb_bind_port(struct inpcb *inp, struc LIST_INSERT_HEAD(INPCBHASH_PORT(table, inp->inp_lport), inp, inp_lhash); - return (0); + return 0; } int @@ -470,14 +470,14 @@ inpcb_bind(void *v, struct sockaddr_in * int error; if (inp->inp_af != AF_INET) - return (EINVAL); + return EINVAL; if (inp->inp_lport || !in_nullhost(in4p_laddr(inp))) - return (EINVAL); + return EINVAL; if (NULL != sin) { if (sin->sin_len != sizeof(*sin)) - return (EINVAL); + return EINVAL; } else { lsin = *((const struct sockaddr_in *) inp->inp_socket->so_proto->pr_domain->dom_sa_any); @@ -487,17 +487,17 @@ inpcb_bind(void *v, struct sockaddr_in * /* Bind address. */ error = inpcb_bind_addr(inp, sin, l->l_cred); if (error) - return (error); + return error; /* Bind port. */ error = inpcb_bind_port(inp, sin, l->l_cred); if (error) { in4p_laddr(inp).s_addr = INADDR_ANY; - return (error); + return error; } - return (0); + return 0; } /* @@ -515,14 +515,14 @@ inpcb_connect(void *v, struct sockaddr_i struct in_addr laddr; if (inp->inp_af != AF_INET) - return (EINVAL); + return EINVAL; if (sin->sin_len != sizeof (*sin)) - return (EINVAL); + return EINVAL; if (sin->sin_family != AF_INET) - return (EAFNOSUPPORT); + return EAFNOSUPPORT; if (sin->sin_port == 0) - return (EADDRNOTAVAIL); + return EADDRNOTAVAIL; if (IN_MULTICAST(sin->sin_addr.s_addr) && inp->inp_socket->so_type == SOCK_STREAM) @@ -589,7 +589,7 @@ inpcb_connect(void *v, struct sockaddr_i pserialize_read_exit(s); ia4_release(ia, &psref); curlwp_bindx(bound); - return (EADDRNOTAVAIL); + return EADDRNOTAVAIL; } pserialize_read_exit(s); laddr = IA_SIN(ia)->sin_addr; @@ -600,7 +600,7 @@ inpcb_connect(void *v, struct sockaddr_i if (inpcb_lookup(inp->inp_table, sin->sin_addr, sin->sin_port, laddr, inp->inp_lport, &vestige) != NULL || vestige.valid) { - return (EADDRINUSE); + return EADDRINUSE; } if (in_nullhost(in4p_laddr(inp))) { if (inp->inp_lport == 0) { @@ -612,7 +612,7 @@ inpcb_connect(void *v, struct sockaddr_i * And attempts to request low ports if not root. */ if (error != 0) - return (error); + return error; } in4p_laddr(inp) = laddr; } @@ -635,7 +635,7 @@ inpcb_connect(void *v, struct sockaddr_i if (ipsec_enabled && inp->inp_socket->so_type == SOCK_STREAM) ipsec_pcbconn(inp->inp_sp); #endif - return (0); + return 0; } void @@ -748,7 +748,7 @@ inpcb_notify(struct inpcbtable *table, s int nmatch; if (in_nullhost(faddr) || notify == NULL) - return (0); + return 0; nmatch = 0; head = INPCBHASH_CONNECT(table, faddr, fport, laddr, lport); @@ -764,7 +764,7 @@ inpcb_notify(struct inpcbtable *table, s nmatch++; } } - return (nmatch); + return nmatch; } void @@ -1019,7 +1019,7 @@ inpcb_lookup_local(struct inpcbtable *ta } } - return (match); + return match; } #ifdef DIAGNOSTIC @@ -1063,7 +1063,7 @@ inpcb_lookup(struct inpcbtable *table, ntohl(laddr.s_addr), ntohs(lport)); } #endif - return (0); + return 0; out: /* Move this PCB to the head of hash chain. */ @@ -1071,7 +1071,7 @@ out: LIST_REMOVE(inp, inp_hash); LIST_INSERT_HEAD(head, inp, inp_hash); } - return (inp); + return inp; } struct inpcb * @@ -1106,7 +1106,7 @@ inpcb_lookup_bound(struct inpcbtable *ta ntohl(laddr.s_addr), ntohs(lport)); } #endif - return (0); + return 0; out: /* Move this PCB to the head of hash chain. */ @@ -1114,7 +1114,7 @@ out: LIST_REMOVE(inp, inp_hash); LIST_INSERT_HEAD(head, inp, inp_hash); } - return (inp); + return inp; } void @@ -1165,7 +1165,7 @@ inpcb_rtentry(struct inpcb *inp) return in6pcb_rtentry(inp); #endif if (inp->inp_af != AF_INET) - return (NULL); + return NULL; ro = &inp->inp_route; Index: src/sys/netinet6/in6_pcb.c diff -u src/sys/netinet6/in6_pcb.c:1.176 src/sys/netinet6/in6_pcb.c:1.177 --- src/sys/netinet6/in6_pcb.c:1.176 Fri Nov 4 09:03:20 2022 +++ src/sys/netinet6/in6_pcb.c Fri Nov 4 09:04:27 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in6_pcb.c,v 1.176 2022/11/04 09:03:20 ozaki-r Exp $ */ +/* $NetBSD: in6_pcb.c,v 1.177 2022/11/04 09:04:27 ozaki-r Exp $ */ /* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.176 2022/11/04 09:03:20 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.177 2022/11/04 09:04:27 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -151,15 +151,15 @@ in6pcb_bind_addr(struct inpcb *inp, stru * incorrectly fail to initialize it. */ if (sin6->sin6_family != AF_INET6) - return (EAFNOSUPPORT); + return EAFNOSUPPORT; #ifndef INET if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) - return (EADDRNOTAVAIL); + return EADDRNOTAVAIL; #endif if ((error = sa6_embedscope(sin6, ip6_use_defzone)) != 0) - return (error); + return error; s = pserialize_read_enter(); if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { @@ -255,7 +255,7 @@ in6pcb_bind_port(struct inpcb *inp, stru error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_BIND, req, so, sin6, NULL); if (error) - return (EACCES); + return EACCES; } if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { @@ -280,13 +280,13 @@ in6pcb_bind_port(struct inpcb *inp, stru *(struct in_addr *)&sin6->sin6_addr.s6_addr32[3], sin6->sin6_port, wild, &vestige); if (t && (reuseport & t->inp_socket->so_options) == 0) - return (EADDRINUSE); + return EADDRINUSE; if (!t && vestige.valid && !(reuseport && vestige.reuse_port)) return EADDRINUSE; #else - return (EADDRNOTAVAIL); + return EADDRNOTAVAIL; #endif } @@ -297,7 +297,7 @@ in6pcb_bind_port(struct inpcb *inp, stru t = in6pcb_lookup_local(table, &sin6->sin6_addr, sin6->sin6_port, wild, &vestige); if (t && (reuseport & t->inp_socket->so_options) == 0) - return (EADDRINUSE); + return EADDRINUSE; if (!t && vestige.valid && !(reuseport && vestige.reuse_port)) @@ -309,7 +309,7 @@ in6pcb_bind_port(struct inpcb *inp, stru int e; e = in6pcb_set_port(sin6, inp, l); if (e != 0) - return (e); + return e; } else { inp->inp_lport = sin6->sin6_port; inpcb_set_state(inp, INP_BOUND); @@ -319,7 +319,7 @@ in6pcb_bind_port(struct inpcb *inp, stru LIST_INSERT_HEAD(IN6PCBHASH_PORT(table, inp->inp_lport), inp, inp_lhash); - return (0); + return 0; } int @@ -330,7 +330,7 @@ in6pcb_bind(void *v, struct sockaddr_in6 int error; if (inp->inp_af != AF_INET6) - return (EINVAL); + return EINVAL; /* * If we already have a local port or a local address it means we're @@ -339,12 +339,12 @@ in6pcb_bind(void *v, struct sockaddr_in6 if (inp->inp_lport || !(IN6_IS_ADDR_UNSPECIFIED(&in6p_laddr(inp)) || (IN6_IS_ADDR_V4MAPPED(&in6p_laddr(inp)) && in6p_laddr(inp).s6_addr32[3] == 0))) - return (EINVAL); + return EINVAL; if (NULL != sin6) { /* We were provided a sockaddr_in6 to use. */ if (sin6->sin6_len != sizeof(*sin6)) - return (EINVAL); + return EINVAL; } else { /* We always bind to *something*, even if it's "anything". */ lsin6 = *((const struct sockaddr_in6 *) @@ -355,7 +355,7 @@ in6pcb_bind(void *v, struct sockaddr_in6 /* Bind address. */ error = in6pcb_bind_addr(inp, sin6, l); if (error) - return (error); + return error; /* Bind port. */ error = in6pcb_bind_port(inp, sin6, l); @@ -366,14 +366,14 @@ in6pcb_bind(void *v, struct sockaddr_in6 */ in6p_laddr(inp) = in6addr_any; - return (error); + return error; } #if 0 in6p_flowinfo(inp) = 0; /* XXX */ #endif - return (0); + return 0; } /* @@ -402,14 +402,14 @@ in6pcb_connect(void *v, struct sockaddr_ (void)&in6a; /* XXX fool gcc */ if (inp->inp_af != AF_INET6) - return (EINVAL); + return EINVAL; if (sin6->sin6_len != sizeof(*sin6)) - return (EINVAL); + return EINVAL; if (sin6->sin6_family != AF_INET6) - return (EAFNOSUPPORT); + return EAFNOSUPPORT; if (sin6->sin6_port == 0) - return (EADDRNOTAVAIL); + return EADDRNOTAVAIL; if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr) && inp->inp_socket->so_type == SOCK_STREAM) @@ -418,7 +418,7 @@ in6pcb_connect(void *v, struct sockaddr_ if (sin6->sin6_scope_id == 0 && !ip6_use_defzone) scope_ambiguous = 1; if ((error = sa6_embedscope(sin6, ip6_use_defzone)) != 0) - return(error); + return error; /* sanity check for mapped address case */ if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { @@ -458,7 +458,7 @@ in6pcb_connect(void *v, struct sockaddr_ if (error == 0) error = EADDRNOTAVAIL; curlwp_bindx(bound); - return (error); + return error; } memset(&mapped, 0, sizeof(mapped)); mapped.s6_addr16[5] = htons(0xffff); @@ -509,7 +509,7 @@ in6pcb_connect(void *v, struct sockaddr_ IN6_IS_ADDR_UNSPECIFIED(&in6p_laddr(inp)) ? in6a : &in6p_laddr(inp), inp->inp_lport, 0, &vestige) || vestige.valid) - return (EADDRINUSE); + return EADDRINUSE; if (IN6_IS_ADDR_UNSPECIFIED(&in6p_laddr(inp)) || (IN6_IS_ADDR_V4MAPPED(&in6p_laddr(inp)) && in6p_laddr(inp).s6_addr32[3] == 0)) @@ -544,7 +544,7 @@ in6pcb_connect(void *v, struct sockaddr_ if (ipsec_enabled && inp->inp_socket->so_type == SOCK_STREAM) ipsec_pcbconn(inp->inp_sp); #endif - return (0); + return 0; } void @@ -958,7 +958,7 @@ in6pcb_lookup_local(struct inpcbtable *t return 0; } } - return (match); + return match; } /* @@ -981,7 +981,7 @@ in6pcb_rtentry(struct inpcb *inp) ro = &inp->inp_route; if (inp->inp_af != AF_INET6) - return (NULL); + return NULL; cdst.sa = rtcache_getdst(ro); if (cdst.sa == NULL) @@ -1152,7 +1152,7 @@ in6pcb_lookup_bound(struct inpcbtable *t if (IN6_ARE_ADDR_EQUAL(&in6p_laddr(inp), &zeroin6_addr)) goto out; } - return (NULL); + return NULL; out: if (inp != LIST_FIRST(head)) {