Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys - fix offsetof usage, and redundant defines
details: https://anonhg.NetBSD.org/src/rev/2629583c33a9
branches: trunk
changeset: 772371:2629583c33a9
user: christos <christos%NetBSD.org@localhost>
date: Sat Dec 31 20:41:58 2011 +0000
description:
- fix offsetof usage, and redundant defines
- kill pointer casts to 0
diffstat:
sys/ddb/db_user.h | 7 +------
sys/net/rtsock.c | 9 ++++++---
sys/net80211/ieee80211_input.c | 8 ++++----
sys/net80211/ieee80211_ioctl.c | 8 ++++----
sys/net80211/ieee80211_netbsd.h | 3 +--
sys/net80211/ieee80211_output.c | 6 +++---
sys/netinet/if_arp.c | 6 +++---
sys/netinet/ip_icmp.c | 7 +++----
sys/netinet/ip_output.c | 6 +++---
sys/netinet/tcp_input.c | 8 ++++----
sys/netinet/tcp_output.c | 9 ++++-----
sys/netinet/tcp_subr.c | 11 +++++------
sys/netinet6/frag6.c | 8 ++------
sys/netinet6/icmp6.c | 10 +++-------
sys/netinet6/in6_ifattach.c | 6 +++---
sys/netinet6/in6_pcb.c | 6 +++---
sys/netinet6/in6_proto.c | 10 +++-------
sys/netinet6/ip6_input.c | 6 +++---
sys/netinet6/ip6_mroute.c | 7 +++----
sys/netinet6/ip6_output.c | 6 +++---
sys/netkey/key.c | 7 ++-----
21 files changed, 66 insertions(+), 88 deletions(-)
diffs (truncated from 645 to 300 lines):
diff -r cf220a1ffd1f -r 2629583c33a9 sys/ddb/db_user.h
--- a/sys/ddb/db_user.h Sat Dec 31 20:16:41 2011 +0000
+++ b/sys/ddb/db_user.h Sat Dec 31 20:41:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_user.h,v 1.2 2010/02/02 09:04:14 tron Exp $ */
+/* $NetBSD: db_user.h,v 1.3 2011/12/31 20:41:58 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -54,11 +54,6 @@
typedef jmp_buf label_t;
-#ifndef offsetof
-#define offsetof(type, member) \
- ((size_t)(unsigned long)(&(((type *)0)->member)))
-#endif
-
int cngetc(void);
void cnputc(int);
diff -r cf220a1ffd1f -r 2629583c33a9 sys/net/rtsock.c
--- a/sys/net/rtsock.c Sat Dec 31 20:16:41 2011 +0000
+++ b/sys/net/rtsock.c Sat Dec 31 20:41:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock.c,v 1.138 2011/12/12 00:06:39 roy Exp $ */
+/* $NetBSD: rtsock.c,v 1.139 2011/12/31 20:41:58 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.138 2011/12/12 00:06:39 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.139 2011/12/31 20:41:58 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -854,11 +854,13 @@
const struct sockaddr *sa;
int pass;
struct mbuf *m;
- struct ifnet *ifp = ifa->ifa_ifp;
+ struct ifnet *ifp;
struct rt_xmsghdr rtm;
struct ifa_xmsghdr ifam;
int ncmd;
+ KASSERT(ifa != NULL);
+ ifp = ifa->ifa_ifp;
COMPATCALL(rt_newaddrmsg, (cmd, ifa, error, rt));
if (COMPATNAME(route_info).ri_cb.any_count == 0)
return;
@@ -885,6 +887,7 @@
ncmd = cmd;
}
info.rti_info[RTAX_IFA] = sa = ifa->ifa_addr;
+ KASSERT(ifp->if_dl != NULL);
info.rti_info[RTAX_IFP] = ifp->if_dl->ifa_addr;
info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr;
diff -r cf220a1ffd1f -r 2629583c33a9 sys/net80211/ieee80211_input.c
--- a/sys/net80211/ieee80211_input.c Sat Dec 31 20:16:41 2011 +0000
+++ b/sys/net80211/ieee80211_input.c Sat Dec 31 20:41:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_input.c,v 1.71 2011/07/17 20:54:52 joerg Exp $ */
+/* $NetBSD: ieee80211_input.c,v 1.72 2011/12/31 20:41:58 christos Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.81 2005/08/10 16:22:29 sam Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.71 2011/07/17 20:54:52 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.72 2011/12/31 20:41:58 christos Exp $");
#endif
#include "opt_inet.h"
@@ -1732,12 +1732,12 @@
wh, "WME", "too short, len %u", len);
return -1;
}
- qosinfo = frm[__offsetof(struct ieee80211_wme_param, param_qosInfo)];
+ qosinfo = frm[offsetof(struct ieee80211_wme_param, param_qosInfo)];
qosinfo &= WME_QOSINFO_COUNT;
/* XXX do proper check for wraparound */
if (qosinfo == wme->wme_wmeChanParams.cap_info)
return 0;
- frm += __offsetof(struct ieee80211_wme_param, params_acParams);
+ frm += offsetof(struct ieee80211_wme_param, params_acParams);
for (i = 0; i < WME_NUM_AC; i++) {
struct wmeParams *wmep =
&wme->wme_wmeChanParams.cap_wmeParams[i];
diff -r cf220a1ffd1f -r 2629583c33a9 sys/net80211/ieee80211_ioctl.c
--- a/sys/net80211/ieee80211_ioctl.c Sat Dec 31 20:16:41 2011 +0000
+++ b/sys/net80211/ieee80211_ioctl.c Sat Dec 31 20:41:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_ioctl.c,v 1.56 2011/06/12 00:07:19 christos Exp $ */
+/* $NetBSD: ieee80211_ioctl.c,v 1.57 2011/12/31 20:41:58 christos Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_ioctl.c,v 1.35 2005/08/30 14:27:47 avatar Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.56 2011/06/12 00:07:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.57 2011/12/31 20:41:58 christos Exp $");
#endif
/*
@@ -962,7 +962,7 @@
chans->ic_chans[chans->ic_nchans].ic_flags = c->ic_flags;
chans->ic_nchans++;
}
- space = __offsetof(struct ieee80211req_chaninfo,
+ space = offsetof(struct ieee80211req_chaninfo,
ic_chans[chans->ic_nchans]);
if (space > ireq->i_len)
space = ireq->i_len;
@@ -1004,7 +1004,7 @@
{
struct ieee80211_node *ni;
u_int8_t macaddr[IEEE80211_ADDR_LEN];
- const size_t off = __offsetof(struct ieee80211req_sta_stats, is_stats);
+ const size_t off = offsetof(struct ieee80211req_sta_stats, is_stats);
int error;
if (ireq->i_len < off)
diff -r cf220a1ffd1f -r 2629583c33a9 sys/net80211/ieee80211_netbsd.h
--- a/sys/net80211/ieee80211_netbsd.h Sat Dec 31 20:16:41 2011 +0000
+++ b/sys/net80211/ieee80211_netbsd.h Sat Dec 31 20:41:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.h,v 1.16 2011/10/07 16:51:45 dyoung Exp $ */
+/* $NetBSD: ieee80211_netbsd.h,v 1.17 2011/12/31 20:41:58 christos Exp $ */
/*-
* Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
* All rights reserved.
@@ -230,7 +230,6 @@
#define RTM_IEEE80211_REJOIN 108 /* station re-associate (ap mode) */
#ifdef _KERNEL
-#define __offsetof offsetof
#define ticks hardclock_ticks
#define ovbcopy(__src, __dst, __n) ((void)memmove(__dst, __src, __n))
diff -r cf220a1ffd1f -r 2629583c33a9 sys/net80211/ieee80211_output.c
--- a/sys/net80211/ieee80211_output.c Sat Dec 31 20:16:41 2011 +0000
+++ b/sys/net80211/ieee80211_output.c Sat Dec 31 20:41:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_output.c,v 1.50 2011/02/21 23:50:08 jmcneill Exp $ */
+/* $NetBSD: ieee80211_output.c,v 1.51 2011/12/31 20:41:58 christos Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_output.c,v 1.34 2005/08/10 16:22:29 sam Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.50 2011/02/21 23:50:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.51 2011/12/31 20:41:58 christos Exp $");
#endif
#include "opt_inet.h"
@@ -1258,7 +1258,7 @@
int i;
memcpy(frm, ¶m, sizeof(param));
- frm += __offsetof(struct ieee80211_wme_info, wme_info);
+ frm += offsetof(struct ieee80211_wme_info, wme_info);
*frm++ = wme->wme_bssChanParams.cap_info; /* AC info */
*frm++ = 0; /* reserved field */
for (i = 0; i < WME_NUM_AC; i++) {
diff -r cf220a1ffd1f -r 2629583c33a9 sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c Sat Dec 31 20:16:41 2011 +0000
+++ b/sys/netinet/if_arp.c Sat Dec 31 20:41:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_arp.c,v 1.152 2011/08/27 09:05:54 christos Exp $ */
+/* $NetBSD: if_arp.c,v 1.153 2011/12/31 20:41:58 christos Exp $ */
/*-
* Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.152 2011/08/27 09:05:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.153 2011/12/31 20:41:58 christos Exp $");
#include "opt_ddb.h"
#include "opt_inet.h"
@@ -1238,7 +1238,7 @@
arps[ARP_STAT_SNDTOTAL]++;
arps[ARP_STAT_SNDREPLY]++;
ARP_STAT_PUTREF();
- (*ifp->if_output)(ifp, m, &sa, (struct rtentry *)0);
+ (*ifp->if_output)(ifp, m, &sa, NULL);
return;
}
diff -r cf220a1ffd1f -r 2629583c33a9 sys/netinet/ip_icmp.c
--- a/sys/netinet/ip_icmp.c Sat Dec 31 20:16:41 2011 +0000
+++ b/sys/netinet/ip_icmp.c Sat Dec 31 20:41:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_icmp.c,v 1.126 2011/12/19 11:59:56 drochner Exp $ */
+/* $NetBSD: ip_icmp.c,v 1.127 2011/12/31 20:41:58 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -94,7 +94,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.126 2011/12/19 11:59:56 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.127 2011/12/31 20:41:58 christos Exp $");
#include "opt_ipsec.h"
@@ -1111,8 +1111,7 @@
struct rtentry *nrt;
error = rtrequest((int) RTM_ADD, dst,
- (struct sockaddr *) rt->rt_gateway,
- (struct sockaddr *) 0,
+ (struct sockaddr *) rt->rt_gateway, NULL,
RTF_GATEWAY | RTF_HOST | RTF_DYNAMIC, &nrt);
if (error) {
rtfree(rt);
diff -r cf220a1ffd1f -r 2629583c33a9 sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c Sat Dec 31 20:16:41 2011 +0000
+++ b/sys/netinet/ip_output.c Sat Dec 31 20:41:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_output.c,v 1.211 2011/12/19 11:59:57 drochner Exp $ */
+/* $NetBSD: ip_output.c,v 1.212 2011/12/31 20:41:59 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.211 2011/12/19 11:59:57 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.212 2011/12/31 20:41:59 christos Exp $");
#include "opt_pfil_hooks.h"
#include "opt_inet.h"
@@ -1006,7 +1006,7 @@
goto sendorfree;
}
m->m_pkthdr.len = mhlen + len;
- m->m_pkthdr.rcvif = (struct ifnet *)0;
+ m->m_pkthdr.rcvif = NULL;
mhip->ip_sum = 0;
KASSERT((m->m_pkthdr.csum_flags & M_CSUM_IPv4) == 0);
if (sw_csum & M_CSUM_IPv4) {
diff -r cf220a1ffd1f -r 2629583c33a9 sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c Sat Dec 31 20:16:41 2011 +0000
+++ b/sys/netinet/tcp_input.c Sat Dec 31 20:41:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_input.c,v 1.319 2011/12/19 11:59:57 drochner Exp $ */
+/* $NetBSD: tcp_input.c,v 1.320 2011/12/31 20:41:59 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.319 2011/12/19 11:59:57 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.320 2011/12/31 20:41:59 christos Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -2261,7 +2261,7 @@
tp->rcv_scale = tp->request_r_scale;
}
TCP_REASS_LOCK(tp);
- (void) tcp_reass(tp, NULL, (struct mbuf *)0, &tlen);
+ (void) tcp_reass(tp, NULL, NULL, &tlen);
/*
* if we didn't have to retransmit the SYN,
* use its rtt as our initial srtt & rtt var.
@@ -2585,7 +2585,7 @@
tp->rcv_scale = tp->request_r_scale;
}
TCP_REASS_LOCK(tp);
- (void) tcp_reass(tp, NULL, (struct mbuf *)0, &tlen);
+ (void) tcp_reass(tp, NULL, NULL, &tlen);
tp->snd_wl1 = th->th_seq - 1;
/* fall into ... */
diff -r cf220a1ffd1f -r 2629583c33a9 sys/netinet/tcp_output.c
--- a/sys/netinet/tcp_output.c Sat Dec 31 20:16:41 2011 +0000
+++ b/sys/netinet/tcp_output.c Sat Dec 31 20:41:58 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_output.c,v 1.172 2011/12/19 11:59:57 drochner Exp $ */
+/* $NetBSD: tcp_output.c,v 1.173 2011/12/31 20:41:59 christos Exp $ */
Home |
Main Index |
Thread Index |
Old Index