Cosmetic: whitespace nits. Shorten a staircase. Remove unnecessary

parentheses and casts.  Compare pointers with NULL instead of 0.
bzero -> memset.
This commit is contained in:
dyoung 2007-01-29 06:55:41 +00:00
parent 741e438b04
commit 7b077b0223
1 changed files with 30 additions and 29 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_eon.c,v 1.54 2006/12/15 21:18:57 joerg Exp $ */
/* $NetBSD: if_eon.c,v 1.55 2007/01/29 06:55:41 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -67,7 +67,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.54 2006/12/15 21:18:57 joerg Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.55 2007/01/29 06:55:41 dyoung Exp $");
#include "opt_eon.h"
@ -215,8 +215,8 @@ eoniphdr(struct eon_iphdr *hdr, const void *loc, struct route *ro,
struct mbuf mhead;
struct sockaddr_in *sin = satosin(&ro->ro_dst);
if (zero) {
bzero((caddr_t) hdr, sizeof(*hdr));
bzero((caddr_t) ro, sizeof(*ro));
memset(hdr, 0, sizeof(*hdr));
memset(ro, 0, sizeof(*ro));
}
sin->sin_family = AF_INET;
sin->sin_len = sizeof(*sin);
@ -238,9 +238,9 @@ eoniphdr(struct eon_iphdr *hdr, const void *loc, struct route *ro,
hdr->ei_eh.eonh_class = class;
hdr->ei_eh.eonh_vers = EON_VERSION;
hdr->ei_eh.eonh_csum = 0;
mhead.m_data = (caddr_t) & hdr->ei_eh;
mhead.m_data = (caddr_t)&hdr->ei_eh;
mhead.m_len = sizeof(struct eon_hdr);
mhead.m_next = 0;
mhead.m_next = NULL;
#ifdef ARGO_DEBUG
if (argo_debug[D_EON]) {
printf("eonoutput : gen csum (%p, offset %lu, datalen %ld)\n",
@ -273,10 +273,10 @@ eonrtrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info)
switch (cmd) {
case RTM_DELETE:
if (el) {
remque(&(el->el_qhdr));
remque(&el->el_qhdr);
rtcache_free(&el->el_iproute);
Free(el);
rt->rt_llinfo = 0;
rt->rt_llinfo = NULL;
}
return;
@ -285,14 +285,15 @@ eonrtrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info)
rt->rt_rmx.rmx_mtu = lo0ifp->if_mtu; /* unless better below */
R_Malloc(el, struct eon_llinfo *, sizeof(*el));
rt->rt_llinfo = (caddr_t) el;
if (el == 0)
if (el == NULL)
return;
Bzero(el, sizeof(*el));
insque(&(el->el_qhdr), &eon_llinfo.el_qhdr);
memset(el, 0, sizeof(*el));
insque(&el->el_qhdr, &eon_llinfo.el_qhdr);
el->el_rt = rt;
break;
}
if (info && (gate = info->rti_info[RTAX_GATEWAY])) /*XXX*/
if (info != NULL &&
(gate = info->rti_info[RTAX_GATEWAY]) != NULL) { /*XXX*/
switch (gate->sa_family) {
case AF_LINK:
#define SDL(x) ((const struct sockaddr_dl *)x)
@ -308,6 +309,7 @@ eonrtrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info)
default:
return;
}
}
el->el_flags |= RTF_UP;
eoniphdr(&el->el_ei, ipaddrloc, &el->el_iproute, EON_NORMAL_ADDR, 0);
if (el->el_iproute.ro_rt != NULL)
@ -333,7 +335,7 @@ int
eonoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sdst,
struct rtentry *rt)
{
struct sockaddr_iso *dst = (struct sockaddr_iso *) sdst;
struct sockaddr_iso *dst = (struct sockaddr_iso *)sdst;
struct eon_llinfo *el;
struct eon_iphdr *ei;
struct route *ro;
@ -351,7 +353,7 @@ eonoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sdst,
#endif
ifp->if_opackets++;
if (rt == 0 || (el = (struct eon_llinfo *) rt->rt_llinfo) == 0) {
if (rt == NULL || (el = (struct eon_llinfo *)rt->rt_llinfo) == NULL) {
if (dst->siso_family == AF_LINK) {
struct sockaddr_dl *sdl = (struct sockaddr_dl *) dst;
@ -388,13 +390,13 @@ einval:
}
ei = &el->el_ei;
ro = &el->el_iproute;
if (el->el_snpaoffset) {
if (dst->siso_family == AF_ISO) {
bcopy((caddr_t) & dst->siso_data[el->el_snpaoffset],
(caddr_t) & ei->ei_ip.ip_dst, sizeof(ei->ei_ip.ip_dst));
} else
goto einval;
}
if (el->el_snpaoffset == 0)
;
else if (dst->siso_family == AF_ISO) {
memcpy(&ei->ei_ip.ip_dst, &dst->siso_data[el->el_snpaoffset],
sizeof(ei->ei_ip.ip_dst));
} else
goto einval;
send:
/* put an eon_hdr in the buffer, prepended by an ip header */
datalen = m->m_pkthdr.len + EONIPLEN;
@ -403,7 +405,7 @@ send:
goto flush;
}
MGETHDR(mh, M_DONTWAIT, MT_HEADER);
if (mh == (struct mbuf *) 0) {
if (mh == NULL) {
error = ENOBUFS;
goto flush;
}
@ -424,16 +426,15 @@ send:
}
#endif
error = ip_output(m, (struct mbuf *) 0, ro, 0,
(struct ip_moptions *)NULL, (struct socket *)NULL);
m = 0;
error = ip_output(m, NULL, ro, 0, NULL, NULL);
m = NULL;
if (error) {
ifp->if_oerrors++;
ifp->if_opackets--;
ifp->if_obytes -= datalen;
}
flush:
if (m)
if (m != NULL)
m_freem(m);
return error;
}
@ -462,12 +463,12 @@ eoninput(struct mbuf *m, ...)
}
#endif
if (m == 0)
if (m == NULL)
return;
if (iphlen > sizeof(struct ip))
ip_stripoptions(m, (struct mbuf *) 0);
ip_stripoptions(m, NULL);
if (m->m_len < EONIPLEN) {
if ((m = m_pullup(m, EONIPLEN)) == 0) {
if ((m = m_pullup(m, EONIPLEN)) == NULL) {
IncStat(es_badhdr);
drop:
#ifdef ARGO_DEBUG