Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet Reduce scopes of variables
details: https://anonhg.NetBSD.org/src/rev/3bd503d00747
branches: trunk
changeset: 816718:3bd503d00747
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Jul 20 03:38:09 2016 +0000
description:
Reduce scopes of variables
diffstat:
sys/netinet/in_pcb.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diffs (72 lines):
diff -r 97a11e529f7e -r 3bd503d00747 sys/netinet/in_pcb.c
--- a/sys/netinet/in_pcb.c Wed Jul 20 03:36:51 2016 +0000
+++ b/sys/netinet/in_pcb.c Wed Jul 20 03:38:09 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in_pcb.c,v 1.166 2016/07/08 04:33:30 ozaki-r Exp $ */
+/* $NetBSD: in_pcb.c,v 1.167 2016/07/20 03:38:09 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.166 2016/07/08 04:33:30 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.167 2016/07/20 03:38:09 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -451,10 +451,9 @@
in_pcbconnect(void *v, struct sockaddr_in *sin, struct lwp *l)
{
struct inpcb *inp = v;
- struct in_ifaddr *ia = NULL;
- struct sockaddr_in *ifaddr = NULL;
vestigial_inpcb_t vestige;
int error;
+ struct in_addr laddr;
if (inp->inp_af != AF_INET)
return (EINVAL);
@@ -484,6 +483,7 @@
sin->sin_addr =
IN_ADDRLIST_READER_FIRST()->ia_addr.sin_addr;
} else if (sin->sin_addr.s_addr == INADDR_BROADCAST) {
+ struct in_ifaddr *ia;
IN_ADDRLIST_READER_FOREACH(ia) {
if (ia->ia_ifp->if_flags & IFF_BROADCAST) {
sin->sin_addr =
@@ -507,6 +507,9 @@
*/
if (in_nullhost(inp->inp_laddr)) {
int xerror;
+ struct sockaddr_in *ifaddr;
+ struct in_ifaddr *ia;
+
ifaddr = in_selectsrc(sin, &inp->inp_route,
inp->inp_socket->so_options, inp->inp_moptions, &xerror);
if (ifaddr == NULL) {
@@ -517,10 +520,11 @@
ia = in_get_ia(ifaddr->sin_addr);
if (ia == NULL)
return (EADDRNOTAVAIL);
- }
+ laddr = ifaddr->sin_addr;
+ } else
+ laddr = inp->inp_laddr;
if (in_pcblookup_connect(inp->inp_table, sin->sin_addr, sin->sin_port,
- !in_nullhost(inp->inp_laddr) ? inp->inp_laddr : ifaddr->sin_addr,
- inp->inp_lport, &vestige) != 0
+ laddr, inp->inp_lport, &vestige) != 0
|| vestige.valid)
return (EADDRINUSE);
if (in_nullhost(inp->inp_laddr)) {
@@ -535,7 +539,7 @@
if (error != 0)
return (error);
}
- inp->inp_laddr = ifaddr->sin_addr;
+ inp->inp_laddr = laddr;
}
inp->inp_faddr = sin->sin_addr;
inp->inp_fport = sin->sin_port;
Home |
Main Index |
Thread Index |
Old Index