Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Avoid error of "-Wreturn-local-addr", and simplify the l...



details:   https://anonhg.NetBSD.org/src/rev/a79cc7c80ebd
branches:  trunk
changeset: 371840:a79cc7c80ebd
user:      ryo <ryo%NetBSD.org@localhost>
date:      Fri Oct 14 19:39:32 2022 +0000

description:
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.

diffstat:

 sys/netinet/in_pcb.c   |  17 +++++++----------
 sys/netinet6/in6_pcb.c |  17 +++++++----------
 2 files changed, 14 insertions(+), 20 deletions(-)

diffs (104 lines):

diff -r ac5fb910d587 -r a79cc7c80ebd sys/netinet/in_pcb.c
--- a/sys/netinet/in_pcb.c      Fri Oct 14 08:10:22 2022 +0000
+++ b/sys/netinet/in_pcb.c      Fri Oct 14 19:39:32 2022 +0000
@@ -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 @@
        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 @@
                                continue;
                        if (wildcard < matchwild) {
                                better = *vp;
-                               match  = (void*)&better;
+                               has_better = true;
 
                                matchwild = wildcard;
                                if (matchwild == 0)
@@ -967,13 +968,9 @@
                        }
                }
 
-               if (match) {
-                       if (match != (void*)&better)
-                               return match;
-                       else {
-                               *vp = better;
-                               return 0;
-                       }
+               if (has_better) {
+                       *vp = better;
+                       return 0;
                }
        }
 
diff -r ac5fb910d587 -r a79cc7c80ebd sys/netinet6/in6_pcb.c
--- a/sys/netinet6/in6_pcb.c    Fri Oct 14 08:10:22 2022 +0000
+++ b/sys/netinet6/in6_pcb.c    Fri Oct 14 19:39:32 2022 +0000
@@ -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 @@
 
        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 @@
                                continue;
                        if (wildcard < matchwild) {
                                better = *vp;
-                               match  = (void*)&better;
+                               has_better = true;
 
                                matchwild = wildcard;
                                if (matchwild == 0)
@@ -1095,13 +1096,9 @@
                        }
                }
 
-               if (match) {
-                       if (match != (void*)&better)
-                               return match;
-                       else {
-                               *vp = better;
-                               return 0;
-                       }
+               if (has_better) {
+                       *vp = better;
+                       return 0;
                }
        }
        return (match);



Home | Main Index | Thread Index | Old Index