Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Remove unnecessary NULL checks of ifa->ifa_addr
details: https://anonhg.NetBSD.org/src/rev/158825b4062b
branches: trunk
changeset: 346071:158825b4062b
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Jun 22 07:48:17 2016 +0000
description:
Remove unnecessary NULL checks of ifa->ifa_addr
If it's NULL, it should be a bug. There many IFADDR_FOREACH that don't do
NULL check. If it can be NULL, they should fire already.
diffstat:
sys/dist/pf/net/pf_if.c | 6 ++----
sys/net/if_stf.c | 6 ++----
sys/netinet6/in6.c | 10 ++--------
sys/netinet6/in6_var.h | 4 +---
sys/netinet6/ip6_input.c | 6 ++----
sys/netinet6/mld6.c | 8 ++------
6 files changed, 11 insertions(+), 29 deletions(-)
diffs (180 lines):
diff -r 762eba78306d -r 158825b4062b sys/dist/pf/net/pf_if.c
--- a/sys/dist/pf/net/pf_if.c Wed Jun 22 07:44:02 2016 +0000
+++ b/sys/dist/pf/net/pf_if.c Wed Jun 22 07:48:17 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pf_if.c,v 1.28 2016/06/16 02:38:40 ozaki-r Exp $ */
+/* $NetBSD: pf_if.c,v 1.29 2016/06/22 07:48:17 ozaki-r Exp $ */
/* $OpenBSD: pf_if.c,v 1.47 2007/07/13 09:17:48 markus Exp $ */
/*
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.28 2016/06/16 02:38:40 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.29 2016/06/22 07:48:17 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -560,8 +560,6 @@
if (ifp == NULL)
return;
IFADDR_FOREACH(ia, ifp) {
- if (ia->ifa_addr == NULL)
- continue;
af = ia->ifa_addr->sa_family;
if (af != AF_INET && af != AF_INET6)
continue;
diff -r 762eba78306d -r 158825b4062b sys/net/if_stf.c
--- a/sys/net/if_stf.c Wed Jun 22 07:44:02 2016 +0000
+++ b/sys/net/if_stf.c Wed Jun 22 07:48:17 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_stf.c,v 1.90 2016/06/10 13:31:44 ozaki-r Exp $ */
+/* $NetBSD: if_stf.c,v 1.91 2016/06/22 07:48:17 ozaki-r Exp $ */
/* $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */
/*
@@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.90 2016/06/10 13:31:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.91 2016/06/22 07:48:17 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -304,8 +304,6 @@
IFADDR_FOREACH(ifa, ifp)
{
- if (ifa->ifa_addr == NULL)
- continue;
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
diff -r 762eba78306d -r 158825b4062b sys/netinet6/in6.c
--- a/sys/netinet6/in6.c Wed Jun 22 07:44:02 2016 +0000
+++ b/sys/netinet6/in6.c Wed Jun 22 07:48:17 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6.c,v 1.199 2016/05/12 02:24:17 ozaki-r Exp $ */
+/* $NetBSD: in6.c,v 1.200 2016/06/22 07:48:17 ozaki-r Exp $ */
/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.199 2016/05/12 02:24:17 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.200 2016/06/22 07:48:17 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1688,8 +1688,6 @@
* and to validate the address if necessary.
*/
IFADDR_FOREACH(ifa, ifp) {
- if (ifa->ifa_addr == NULL)
- continue; /* just for safety */
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
ifacount++;
@@ -1758,8 +1756,6 @@
struct ifaddr *best_ifa = NULL, *ifa;
IFADDR_FOREACH(ifa, ifp) {
- if (ifa->ifa_addr == NULL)
- continue; /* just for safety */
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
if (!IN6_IS_ADDR_LINKLOCAL(IFA_IN6(ifa)))
@@ -1810,8 +1806,6 @@
struct ifaddr *best_ifa = NULL, *ifa;
IFADDR_FOREACH(ifa, ifp) {
- if (ifa->ifa_addr == NULL)
- continue; /* just for safety */
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
if (!IN6_ARE_ADDR_EQUAL(addr, IFA_IN6(ifa)))
diff -r 762eba78306d -r 158825b4062b sys/netinet6/in6_var.h
--- a/sys/netinet6/in6_var.h Wed Jun 22 07:44:02 2016 +0000
+++ b/sys/netinet6/in6_var.h Wed Jun 22 07:48:17 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_var.h,v 1.76 2016/02/04 02:48:37 riastradh Exp $ */
+/* $NetBSD: in6_var.h,v 1.77 2016/06/22 07:48:17 ozaki-r Exp $ */
/* $KAME: in6_var.h,v 1.81 2002/06/08 11:16:51 itojun Exp $ */
/*
@@ -514,8 +514,6 @@
struct ifaddr *ifa;
IFADDR_FOREACH(ifa, ifp) {
- if (ifa->ifa_addr == NULL)
- continue;
if (ifa->ifa_addr->sa_family == AF_INET6)
break;
}
diff -r 762eba78306d -r 158825b4062b sys/netinet6/ip6_input.c
--- a/sys/netinet6/ip6_input.c Wed Jun 22 07:44:02 2016 +0000
+++ b/sys/netinet6/ip6_input.c Wed Jun 22 07:48:17 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_input.c,v 1.160 2016/06/10 13:31:44 ozaki-r Exp $ */
+/* $NetBSD: ip6_input.c,v 1.161 2016/06/22 07:48:17 ozaki-r Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.160 2016/06/10 13:31:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.161 2016/06/22 07:48:17 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_gateway.h"
@@ -534,8 +534,6 @@
*/
struct ifaddr *ifa;
IFADDR_FOREACH(ifa, rcvif) {
- if (ifa->ifa_addr == NULL)
- continue; /* just for safety */
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
if (IN6_ARE_ADDR_EQUAL(IFA_IN6(ifa), &ip6->ip6_dst)) {
diff -r 762eba78306d -r 158825b4062b sys/netinet6/mld6.c
--- a/sys/netinet6/mld6.c Wed Jun 22 07:44:02 2016 +0000
+++ b/sys/netinet6/mld6.c Wed Jun 22 07:48:17 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mld6.c,v 1.68 2016/06/21 03:28:27 ozaki-r Exp $ */
+/* $NetBSD: mld6.c,v 1.69 2016/06/22 07:48:17 ozaki-r Exp $ */
/* $KAME: mld6.c,v 1.25 2001/01/16 14:14:18 itojun Exp $ */
/*
@@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.68 2016/06/21 03:28:27 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.69 2016/06/22 07:48:17 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -998,8 +998,6 @@
if (oldp == NULL) {
*oldlenp = 0;
IFADDR_FOREACH(ifa, ifp) {
- if (ifa->ifa_addr == NULL)
- continue;
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
ifa6 = (struct in6_ifaddr *)ifa;
@@ -1016,8 +1014,6 @@
error = 0;
written = 0;
IFADDR_FOREACH(ifa, ifp) {
- if (ifa->ifa_addr == NULL)
- continue;
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
ifa6 = (struct in6_ifaddr *)ifa;
Home |
Main Index |
Thread Index |
Old Index