Module Name:    src
Committed By:   ryo
Date:           Fri Oct 14 19:39:32 UTC 2022

Modified Files:
        src/sys/netinet: in_pcb.c
        src/sys/netinet6: in6_pcb.c

Log Message:
Avoid error of "-Wreturn-local-addr", and simplify the logic.

However, -Wreturn-local-addr is still disabled by default by 
GCC_NO_RETURN_LOCAL_ADDR
in bsd.own.mk because it causes errors in other parts.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/sys/netinet/in_pcb.c
cvs rdiff -u -r1.170 -r1.171 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.190 src/sys/netinet/in_pcb.c:1.191
--- src/sys/netinet/in_pcb.c:1.190	Mon Aug 29 09:14:02 2022
+++ src/sys/netinet/in_pcb.c	Fri Oct 14 19:39:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_pcb.c,v 1.190 2022/08/29 09:14:02 knakahara Exp $	*/
+/*	$NetBSD: in_pcb.c,v 1.191 2022/10/14 19:39:32 ryo 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.190 2022/08/29 09:14:02 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.191 2022/10/14 19:39:32 ryo Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -935,6 +935,7 @@ in_pcblookup_port(struct inpcbtable *tab
 	if (vp && table->vestige) {
 		void	*state = (*table->vestige->init_ports4)(laddr, lport_arg, lookup_wildcard);
 		vestigial_inpcb_t better;
+		bool has_better = false;
 
 		while (table->vestige
 		       && (*table->vestige->next_port4)(state, vp)) {
@@ -959,7 +960,7 @@ in_pcblookup_port(struct inpcbtable *tab
 				continue;
 			if (wildcard < matchwild) {
 				better = *vp;
-				match  = (void*)&better;
+				has_better = true;
 
 				matchwild = wildcard;
 				if (matchwild == 0)
@@ -967,13 +968,9 @@ in_pcblookup_port(struct inpcbtable *tab
 			}
 		}
 
-		if (match) {
-			if (match != (void*)&better)
-				return match;
-			else {
-				*vp = better;
-				return 0;
-			}
+		if (has_better) {
+			*vp = better;
+			return 0;
 		}
 	}
 

Index: src/sys/netinet6/in6_pcb.c
diff -u src/sys/netinet6/in6_pcb.c:1.170 src/sys/netinet6/in6_pcb.c:1.171
--- src/sys/netinet6/in6_pcb.c:1.170	Mon Aug 29 09:14:02 2022
+++ src/sys/netinet6/in6_pcb.c	Fri Oct 14 19:39:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_pcb.c,v 1.170 2022/08/29 09:14:02 knakahara Exp $	*/
+/*	$NetBSD: in6_pcb.c,v 1.171 2022/10/14 19:39:32 ryo 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.170 2022/08/29 09:14:02 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.171 2022/10/14 19:39:32 ryo Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1055,6 +1055,7 @@ in6_pcblookup_port(struct inpcbtable *ta
 
 	if (vp && table->vestige && table->vestige->init_ports6) {
 		struct vestigial_inpcb better;
+		bool has_better = false;
 		void *state;
 
 		state = (*table->vestige->init_ports6)(laddr6,
@@ -1087,7 +1088,7 @@ in6_pcblookup_port(struct inpcbtable *ta
 				continue;
 			if (wildcard < matchwild) {
 				better = *vp;
-				match  = (void*)&better;
+				has_better = true;
 
 				matchwild = wildcard;
 				if (matchwild == 0)
@@ -1095,13 +1096,9 @@ in6_pcblookup_port(struct inpcbtable *ta
 			}
 		}
 
-		if (match) {
-			if (match != (void*)&better)
-				return match;
-			else {
-				*vp = better;
-				return 0;
-			}
+		if (has_better) {
+			*vp = better;
+			return 0;
 		}
 	}
 	return (match);

Reply via email to