Use offsetof() from libkern.h

This commit is contained in:
thorpej 1998-01-28 02:35:10 +00:00
parent 2538ed1062
commit 4c54445530
9 changed files with 16 additions and 29 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_log.c,v 1.13 1997/09/19 13:56:40 leo Exp $ */
/* $NetBSD: subr_log.c,v 1.14 1998/01/28 02:35:10 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@ -82,9 +82,7 @@ initmsgbuf(buf, bufsize)
mbp = msgbufp = (struct kern_msgbuf *)buf;
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
new_bufs = bufsize - offsetof(struct kern_msgbuf, msg_bufc);
#undef offsetof
if ((mbp->msg_magic != MSG_MAGIC) || (mbp->msg_bufs != new_bufs) ||
(mbp->msg_bufr < 0) || (mbp->msg_bufr >= mbp->msg_bufs) ||
(mbp->msg_bufx < 0) || (mbp->msg_bufx >= mbp->msg_bufs)) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: if.c,v 1.42 1997/10/02 19:41:56 is Exp $ */
/* $NetBSD: if.c,v 1.43 1998/01/28 02:35:30 thorpej Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -102,8 +102,7 @@ if_attach(ifp)
* create a Link Level name for this device
*/
namelen = strlen(ifp->if_xname);
#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))
masklen = _offsetof(struct sockaddr_dl, sdl_data[0]) + namelen;
masklen = offsetof(struct sockaddr_dl, sdl_data[0]) + namelen;
socksize = masklen + ifp->if_addrlen;
#define ROUNDUP(a) (1 + (((a) - 1) | (sizeof(long) - 1)))
if (socksize < sizeof(*sdl))

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_x25subr.c,v 1.16 1996/10/13 02:10:06 christos Exp $ */
/* $NetBSD: if_x25subr.c,v 1.17 1998/01/28 02:35:50 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
@ -81,12 +81,9 @@
LIST_HEAD(, llinfo_x25) llinfo_x25;
#ifndef _offsetof
#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))
#endif
struct sockaddr *x25_dgram_sockmask;
struct sockaddr_x25 x25_dgmask = {
_offsetof(struct sockaddr_x25, x25_udata[1]), /* _len */
offsetof(struct sockaddr_x25, x25_udata[1]), /* _len */
0, /* _family */
0, /* _net */
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* _addr */

View File

@ -1,4 +1,4 @@
/* $NetBSD: pk_usrreq.c,v 1.13 1996/10/10 22:58:29 christos Exp $ */
/* $NetBSD: pk_usrreq.c,v 1.14 1998/01/28 02:35:51 thorpej Exp $ */
/*
* Copyright (c) University of British Columbia, 1984
@ -336,11 +336,8 @@ pk_start(lcp)
return (0); /* XXX pk_output should return a value */
}
#ifndef _offsetof
#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))
#endif
struct sockaddr_x25 pk_sockmask = {
_offsetof(struct sockaddr_x25, x25_addr[0]), /* x25_len */
offsetof(struct sockaddr_x25, x25_addr[0]), /* x25_len */
0, /* x25_family */
-1, /* x25_net id */
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_input.c,v 1.55 1998/01/12 03:02:51 scottr Exp $ */
/* $NetBSD: ip_input.c,v 1.56 1998/01/28 02:36:10 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1993
@ -66,9 +66,6 @@
#include <netinet/ip_var.h>
#include <netinet/ip_icmp.h>
/* XXX should really put this in libkern.h */
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
#ifndef IPFORWARDING
#ifdef GATEWAY
#define IPFORWARDING 1 /* forward IP packets not for us */

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnp_input.c,v 1.15 1997/03/15 18:12:37 is Exp $ */
/* $NetBSD: clnp_input.c,v 1.16 1998/01/28 02:38:44 thorpej Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -198,7 +198,7 @@ next:
bcopy(sizeof(u_long) + mtod(m, caddr_t),
(caddr_t) sh.snh_shost, sizeof(u_long));
sh.snh_dhost[4] = mtod(m, u_char *)[sizeof(struct ip) +
_offsetof(struct eon_hdr, eonh_class)];
offsetof(struct eon_hdr, eonh_class)];
m->m_data += EONIPLEN;
m->m_len -= EONIPLEN;
m->m_pkthdr.len -= EONIPLEN;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_eon.c,v 1.21 1998/01/16 18:54:10 cgd Exp $ */
/* $NetBSD: if_eon.c,v 1.22 1998/01/28 02:38:45 thorpej Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -257,12 +257,12 @@ eoniphdr(hdr, loc, ro, class, zero)
#ifdef ARGO_DEBUG
if (argo_debug[D_EON]) {
printf("eonoutput : gen csum (%p, offset %d, datalen %ld)\n",
&mhead, _offsetof(struct eon_hdr, eonh_csum),
&mhead, offsetof(struct eon_hdr, eonh_csum),
(long)sizeof(struct eon_hdr));
}
#endif
iso_gen_csum(&mhead,
_offsetof(struct eon_hdr, eonh_csum), sizeof(struct eon_hdr));
offsetof(struct eon_hdr, eonh_csum), sizeof(struct eon_hdr));
}
/*
* FUNCTION: eonrtrequest

View File

@ -1,4 +1,4 @@
/* $NetBSD: iso.h,v 1.8 1996/02/13 22:09:58 christos Exp $ */
/* $NetBSD: iso.h,v 1.9 1998/01/28 02:38:45 thorpej Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -192,5 +192,4 @@ __END_DECLS
#endif /* _KERNEL */
#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))
#endif /* _NETISO_ISO_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: iso_pcb.c,v 1.14 1997/06/24 02:26:10 thorpej Exp $ */
/* $NetBSD: iso_pcb.c,v 1.15 1998/01/28 02:38:46 thorpej Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -370,7 +370,7 @@ iso_pcbconnect(v, nam)
oldtsel = TSEL(siso);
tlen = siso->siso_tlen;
nlen = ia->ia_addr.siso_nlen;
totlen = tlen + nlen + _offsetof(struct sockaddr_iso, siso_data[0]);
totlen = tlen + nlen + offsetof(struct sockaddr_iso, siso_data[0]);
if ((siso == &isop->isop_sladdr) &&
(totlen > sizeof(isop->isop_sladdr))) {
struct mbuf *m = m_get(M_DONTWAIT, MT_SONAME);