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.
This commit is contained in:
parent
8ecbf38c3b
commit
0563f74f12
|
@ -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 *table, struct in_addr laddr,
|
|||
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 *table, struct in_addr laddr,
|
|||
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 *table, struct in_addr laddr,
|
|||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
if (match != (void*)&better)
|
||||
return match;
|
||||
else {
|
||||
*vp = better;
|
||||
return 0;
|
||||
}
|
||||
if (has_better) {
|
||||
*vp = better;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 *table, struct in6_addr *laddr6,
|
|||
|
||||
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 *table, struct in6_addr *laddr6,
|
|||
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 *table, struct in6_addr *laddr6,
|
|||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
if (match != (void*)&better)
|
||||
return match;
|
||||
else {
|
||||
*vp = better;
|
||||
return 0;
|
||||
}
|
||||
if (has_better) {
|
||||
*vp = better;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return (match);
|
||||
|
|
Loading…
Reference in New Issue