git: 6df9fa1c6b83 - releng/14.1 - sys/netinet6/in6_pcb.c: fix compile without INET
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 21 May 2024 20:09:16 UTC
The branch releng/14.1 has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=6df9fa1c6b8391e09bf74195d302ab12286a1d8a
commit 6df9fa1c6b8391e09bf74195d302ab12286a1d8a
Author: Lexi Winter <lexi@le-Fay.ORG>
AuthorDate: 2024-04-12 16:54:24 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-05-21 20:08:41 +0000
sys/netinet6/in6_pcb.c: fix compile without INET
in6_mapped_sockaddr() and in6_mapped_peeraddr() both define a local
variable named 'inp', but in the non-INET case, this variable is set
and never used, causing a compiler error:
/src/freebsd/src/lf/sys/netinet6/in6_pcb.c:547:16: error:
variable 'inp' set but not used [-Werror,-Wunused-but-set-variable]
547 | struct inpcb *inp;
| ^
/src/freebsd/src/lf/sys/netinet6/in6_pcb.c:573:16: error:
variable 'inp' set but not used [-Werror,-Wunused-but-set-variable]
573 | struct inpcb *inp;
Fix this by guarding all the INET-specific logic, including the variable
definition, behind #ifdef INET.
While here, tweak formatting in in6_mapped_peeraddr() so both functions
are the same.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1155
(cherry picked from commit 042fb58d009e7efc5b334b68fffbef9b1f620ec8)
(cherry picked from commit f30c2d86c39f8c3090e1f8967c13f2dd0d5d664b)
Approved-by: re (cperciva)
---
sys/netinet6/in6_pcb.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index 5c4ef7570ddc..90f91eef1daa 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -579,13 +579,13 @@ in6_getpeeraddr(struct socket *so, struct sockaddr **nam)
int
in6_mapped_sockaddr(struct socket *so, struct sockaddr **nam)
{
- struct inpcb *inp;
int error;
+#ifdef INET
+ struct inpcb *inp;
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("in6_mapped_sockaddr: inp == NULL"));
-#ifdef INET
if ((inp->inp_vflag & (INP_IPV4 | INP_IPV6)) == INP_IPV4) {
error = in_getsockaddr(so, nam);
if (error == 0)
@@ -603,21 +603,23 @@ in6_mapped_sockaddr(struct socket *so, struct sockaddr **nam)
int
in6_mapped_peeraddr(struct socket *so, struct sockaddr **nam)
{
- struct inpcb *inp;
int error;
+#ifdef INET
+ struct inpcb *inp;
inp = sotoinpcb(so);
KASSERT(inp != NULL, ("in6_mapped_peeraddr: inp == NULL"));
-#ifdef INET
if ((inp->inp_vflag & (INP_IPV4 | INP_IPV6)) == INP_IPV4) {
error = in_getpeeraddr(so, nam);
if (error == 0)
in6_sin_2_v4mapsin6_in_sock(nam);
} else
#endif
- /* scope issues will be handled in in6_getpeeraddr(). */
- error = in6_getpeeraddr(so, nam);
+ {
+ /* scope issues will be handled in in6_getpeeraddr(). */
+ error = in6_getpeeraddr(so, nam);
+ }
return error;
}