Avoid casts as lvalues.

This commit is contained in:
Alexander Kabaev 2004-07-28 06:59:55 +00:00
parent 766f8c9247
commit 445e045b0d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=132780
11 changed files with 37 additions and 24 deletions

View File

@ -276,7 +276,7 @@ if_simloop(ifp, m, af, hlen)
(char *)(mtod(m, vm_offset_t)
- (mtod(m, vm_offset_t) & 3)),
m->m_len);
mtod(m,vm_offset_t) -= (mtod(m, vm_offset_t) & 3);
m->m_data -= (mtod(m,vm_offset_t) & 3);
}
#endif
}

View File

@ -1021,7 +1021,7 @@ rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate)
*/
bcopy(dst, new, dlen);
Free(rt_key(rt)); /* free old block, if any */
rt_key(rt) = new;
rt_key(rt) = (struct sockaddr *)new;
rt->rt_gateway = (struct sockaddr *)(new + dlen);
}

View File

@ -105,8 +105,8 @@ struct rtentry {
* because the code does some casts of a 'struct radix_node *'
* to a 'struct rtentry *'
*/
#define rt_key(r) ((struct sockaddr *)((r)->rt_nodes->rn_key))
#define rt_mask(r) ((struct sockaddr *)((r)->rt_nodes->rn_mask))
#define rt_key(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_key)))
#define rt_mask(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_mask)))
struct sockaddr *rt_gateway; /* value */
u_long rt_flags; /* up/down?, host/net */
struct ifnet *rt_ifp; /* the answer: interface to use */

View File

@ -502,7 +502,7 @@ xdrmbuf_getlong(xdrs, lp)
/*
* Advance the data stream
*/
((long *)xdrs->x_private)++;
xdrs->x_private = (long *)xdrs->x_private + 1;
return (TRUE);
}
@ -558,7 +558,7 @@ xdrmbuf_putlong(xdrs, lp)
/*
* Advance the data stream
*/
((long *)xdrs->x_private)++;
xdrs->x_private = (long *)xdrs->x_private + 1;
return (TRUE);
}
@ -605,7 +605,7 @@ xdrmbuf_getbytes(xdrs, addr, len)
/*
* Update data stream controls
*/
((char *)xdrs->x_private) += copy;
xdrs->x_private = (char *)xdrs->x_private + copy;
xdrs->x_handy -= copy;
addr += copy;
len -= copy;
@ -656,7 +656,7 @@ xdrmbuf_putbytes(xdrs, addr, len)
/*
* Update data stream controls
*/
((char *)xdrs->x_private)++;
xdrs->x_private = (char *)xdrs->x_private + 1; /*XXXKAN:copy? */
xdrs->x_handy -= copy;
addr += copy;
len -= copy;

View File

@ -345,6 +345,7 @@ static const struct {
#define IFP2NG(IFP) ((node_p)((struct ifatm *)(IFP))->ngpriv)
#define IFP2NG_SET(IFP, val) (((struct ifatm *)(IFP))->ngpriv = (val))
#define IFFLAGS "\020\001UP\002BROADCAST\003DEBUG\004LOOPBACK" \
"\005POINTOPOINT\006SMART\007RUNNING\010NOARP" \
@ -1280,7 +1281,7 @@ ng_atm_attach(struct ifnet *ifp)
NG_NODE_SET_PRIVATE(node, priv);
priv->ifp = ifp;
LIST_INIT(&priv->vccs);
IFP2NG(ifp) = node;
IFP2NG_SET(ifp, node);
if (ng_name_node(node, name) != 0) {
log(LOG_WARNING, "%s: can't name node %s\n",
@ -1303,7 +1304,7 @@ ng_atm_detach(struct ifnet *ifp)
NG_NODE_REALLY_DIE(node);
priv = NG_NODE_PRIVATE(node);
IFP2NG(priv->ifp) = NULL;
IFP2NG_SET(priv->ifp, NULL);
priv->ifp = NULL;
ng_rmnode_self(node);
@ -1334,7 +1335,7 @@ ng_atm_shutdown(node_p node)
if (!allow_shutdown)
NG_NODE_REVIVE(node); /* we persist */
else {
IFP2NG(priv->ifp) = NULL;
IFP2NG_SET(priv->ifp, NULL);
NG_NODE_SET_PRIVATE(node, NULL);
free(priv, M_NETGRAPH);
NG_NODE_UNREF(node);

View File

@ -65,6 +65,7 @@
#include <netgraph/ng_ether.h>
#define IFP2NG(ifp) ((struct ng_node *)((struct arpcom *)(ifp))->ac_netgraph)
#define IFP2NG_SET(ifp, val) (((struct arpcom *)(ifp))->ac_netgraph = (val))
/* Per-node private data */
struct private {
@ -276,7 +277,7 @@ ng_ether_attach(struct ifnet *ifp)
}
NG_NODE_SET_PRIVATE(node, priv);
priv->ifp = ifp;
IFP2NG(ifp) = node;
IFP2NG_SET(ifp, node);
priv->autoSrcAddr = 1;
priv->hwassist = ifp->if_hwassist;
@ -305,7 +306,7 @@ ng_ether_detach(struct ifnet *ifp)
* So zap it now. XXX We HOPE that anything running at this time
* handles it (as it should in the non netgraph case).
*/
IFP2NG(ifp) = NULL;
IFP2NG_SET(ifp, NULL);
priv->ifp = NULL; /* XXX race if interrupted an output packet */
ng_rmnode_self(node); /* remove all netgraph parts */
}

View File

@ -134,6 +134,7 @@
* should be unused, so we can use to hold our node context.
*/
#define IFP2NG(ifp) (struct ng_node *)(ifp->if_afdata[AF_NETGRAPH])
#define IFP2NG_SET(ifp, val) ifp->if_afdata[AF_NETGRAPH] = (val);
#define FEC_INC(x, y) (x) = (x + 1) % y
/*

View File

@ -88,6 +88,7 @@
#include <netgraph/ng_gif.h>
#define IFP2NG(ifp) ((struct ng_node *)((struct gif_softc *)(ifp))->gif_netgraph)
#define IFP2NG_SET(ifp, val) (((struct gif_softc *)(ifp))->gif_netgraph = (val))
/* Per-node private data */
struct private {
@ -247,7 +248,7 @@ ng_gif_attach(struct ifnet *ifp)
}
NG_NODE_SET_PRIVATE(node, priv);
priv->ifp = ifp;
IFP2NG(ifp) = node;
IFP2NG_SET(ifp, node);
/* Try to give the node the same name as the interface */
if (ng_name_node(node, ifp->if_xname) != 0) {
@ -275,7 +276,7 @@ ng_gif_detach(struct ifnet *ifp)
* So zap it now. XXX We HOPE that anything running at this time
* handles it (as it should in the non netgraph case).
*/
IFP2NG(ifp) = NULL;
IFP2NG_SET(ifp, NULL);
priv->ifp = NULL; /* XXX race if interrupted an output packet */
ng_rmnode_self(node); /* remove all netgraph parts */
}

View File

@ -1115,7 +1115,7 @@ ng_bytearray_parse(const struct ng_parse_type *type,
struct ng_parse_type subtype;
subtype = ng_parse_bytearray_subtype;
(const void *)subtype.private = type->info;
*(const void **)&subtype.private = type->info;
return ng_array_parse(&subtype, s, off, start, buf, buflen);
}
}
@ -1127,7 +1127,7 @@ ng_bytearray_unparse(const struct ng_parse_type *type,
struct ng_parse_type subtype;
subtype = ng_parse_bytearray_subtype;
(const void *)subtype.private = type->info;
*(const void **)&subtype.private = type->info;
return ng_array_unparse(&subtype, data, off, cbuf, cbuflen);
}
@ -1138,7 +1138,7 @@ ng_bytearray_getDefault(const struct ng_parse_type *type,
struct ng_parse_type subtype;
subtype = ng_parse_bytearray_subtype;
(const void *)subtype.private = type->info;
*(const void **)&subtype.private = type->info;
return ng_array_getDefault(&subtype, start, buf, buflen);
}

View File

@ -118,13 +118,16 @@ smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
struct smb_cred *scred, struct smb_vc **vcpp)
{
struct thread *td = scred->scr_td;
struct smb_connobj *scp;
struct smb_vc *vcp;
int exact = 1;
int error;
vcspec->shspec = shspec;
error = ENOENT;
SMBCO_FOREACH((struct smb_connobj*)vcp, &smb_vclist) {
vcp = NULL;
SMBCO_FOREACH(scp, &smb_vclist) {
vcp = (struct smb_vc *)scp;
error = smb_vc_lock(vcp, LK_EXCLUSIVE, td);
if (error)
continue;
@ -594,12 +597,14 @@ smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *dp,
struct smb_cred *scred, struct smb_share **sspp)
{
struct thread *td = scred->scr_td;
struct smb_connobj *scp = NULL;
struct smb_share *ssp = NULL;
int error;
*sspp = NULL;
dp->scred = scred;
SMBCO_FOREACH((struct smb_connobj*)ssp, VCTOCP(vcp)) {
SMBCO_FOREACH(scp, VCTOCP(vcp)) {
ssp = (struct smb_share *)scp;
error = smb_share_lock(ssp, LK_EXCLUSIVE, td);
if (error)
continue;
@ -848,6 +853,7 @@ smb_sysctl_treedump(SYSCTL_HANDLER_ARGS)
{
struct thread *td = req->td;
struct smb_cred scred;
struct smb_connobj *scp1, *scp2;
struct smb_vc *vcp;
struct smb_share *ssp;
struct smb_vc_info vci;
@ -861,7 +867,8 @@ smb_sysctl_treedump(SYSCTL_HANDLER_ARGS)
error = smb_sm_lockvclist(LK_SHARED, td);
if (error)
return error;
SMBCO_FOREACH((struct smb_connobj*)vcp, &smb_vclist) {
SMBCO_FOREACH(scp1, &smb_vclist) {
vcp = (struct smb_vc *)scp1;
error = smb_vc_lock(vcp, LK_SHARED, td);
if (error)
continue;
@ -871,7 +878,8 @@ smb_sysctl_treedump(SYSCTL_HANDLER_ARGS)
smb_vc_unlock(vcp, 0, td);
break;
}
SMBCO_FOREACH((struct smb_connobj*)ssp, VCTOCP(vcp)) {
SMBCO_FOREACH(scp2, VCTOCP(vcp)) {
ssp = (struct smb_share *)scp2;
error = smb_share_lock(ssp, LK_SHARED, td);
if (error) {
error = 0;

View File

@ -1439,7 +1439,8 @@ nfs4_writerpc(struct vnode *vp, struct uio *uiop, struct ucred *cred,
break;
} else if (rlen < len) {
backup = len - rlen;
(char *)uiop->uio_iov->iov_base -= backup;
uiop->uio_iov->iov_base =
(char *)uiop->uio_iov->iov_base - backup;
uiop->uio_iov->iov_len += backup;
uiop->uio_offset -= backup;
uiop->uio_resid += backup;
@ -2146,7 +2147,7 @@ nfs4_readdirrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred)
blksiz = 0;
uiop->uio_offset += len;
uiop->uio_resid -= len;
(char *)uiop->uio_iov->iov_base += len;
uiop->uio_iov->iov_base = (char *)uiop->uio_iov->iov_base + len;
uiop->uio_iov->iov_len -= len;
}