summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2016-05-23 18:28:23 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2016-05-23 18:28:23 +0000
commit42cab10989137c208abb8ef28a8c5cda259bfff7 (patch)
tree69617fb4d1f6501b03b362e7cc6ef30315f9b5cd
parent0b130996a39b6d23b9c9d70d1eec552eae3f977a (diff)
Copy structs by assignment instead of memcpy.
Copying by straight assignment is shorter, easier to read and has a higher level of abstraction. We'll only avoid it when copying from an unaligned source (e.g., network buffers). In addition, copy in_addr structs directly.
-rw-r--r--usr.sbin/ldpd/adjacency.c10
-rw-r--r--usr.sbin/ldpd/hello.c8
-rw-r--r--usr.sbin/ldpd/interface.c16
-rw-r--r--usr.sbin/ldpd/kroute.c31
-rw-r--r--usr.sbin/ldpd/lde.c26
-rw-r--r--usr.sbin/ldpd/lde_lib.c8
-rw-r--r--usr.sbin/ldpd/ldpd.c6
-rw-r--r--usr.sbin/ldpd/neighbor.c16
-rw-r--r--usr.sbin/ldpd/parse.y12
-rw-r--r--usr.sbin/ldpd/pfkey.c6
10 files changed, 69 insertions, 70 deletions
diff --git a/usr.sbin/ldpd/adjacency.c b/usr.sbin/ldpd/adjacency.c
index a82393458ac..69b5637f626 100644
--- a/usr.sbin/ldpd/adjacency.c
+++ b/usr.sbin/ldpd/adjacency.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: adjacency.c,v 1.14 2016/05/23 17:43:42 renato Exp $ */
+/* $OpenBSD: adjacency.c,v 1.15 2016/05/23 18:28:22 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -51,7 +51,7 @@ adj_new(struct nbr *nbr, struct hello_source *source, struct in_addr addr)
fatal(__func__);
adj->nbr = nbr;
- memcpy(&adj->source, source, sizeof(*source));
+ adj->source = *source;
adj->addr = addr;
evtimer_set(&adj->inactivity_timer, adj_itimer, adj);
@@ -168,7 +168,7 @@ tnbr_new(struct ldpd_conf *xconf, struct in_addr addr)
if ((tnbr = calloc(1, sizeof(*tnbr))) == NULL)
fatal(__func__);
- tnbr->addr.s_addr = addr.s_addr;
+ tnbr->addr = addr;
tnbr->hello_holdtime = xconf->thello_holdtime;
tnbr->hello_interval = xconf->thello_interval;
@@ -255,7 +255,7 @@ adj_to_ctl(struct adj *adj)
{
static struct ctl_adj actl;
- actl.id.s_addr = adj->nbr->id.s_addr;
+ actl.id = adj->nbr->id;
actl.type = adj->source.type;
switch (adj->source.type) {
case HELLO_LINK:
@@ -263,7 +263,7 @@ adj_to_ctl(struct adj *adj)
sizeof(actl.ifname));
break;
case HELLO_TARGETED:
- actl.src_addr.s_addr = adj->source.target->addr.s_addr;
+ actl.src_addr = adj->source.target->addr;
break;
}
actl.holdtime = adj->holdtime;
diff --git a/usr.sbin/ldpd/hello.c b/usr.sbin/ldpd/hello.c
index 3b0f5730f35..6b1497b1c77 100644
--- a/usr.sbin/ldpd/hello.c
+++ b/usr.sbin/ldpd/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.37 2016/05/23 17:43:42 renato Exp $ */
+/* $OpenBSD: hello.c,v 1.38 2016/05/23 18:28:22 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -63,7 +63,7 @@ send_hello(enum hello_type type, struct iface *iface, struct tnbr *tnbr)
fd = global.ldp_disc_socket;
break;
case HELLO_TARGETED:
- dst.sin_addr.s_addr = tnbr->addr.s_addr;
+ dst.sin_addr = tnbr->addr;
holdtime = tnbr->hello_holdtime;
flags = TARGETED_HELLO;
if ((tnbr->flags & F_TNBR_CONFIGURED) || tnbr->pw_count)
@@ -158,7 +158,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *lm, struct in_addr src,
} else {
source.type = HELLO_LINK;
source.link.iface = iface;
- source.link.src_addr.s_addr = src.s_addr;
+ source.link.src_addr = src;
}
r = tlv_decode_opt_hello_prms(buf, len, &transport_addr,
@@ -176,7 +176,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *lm, struct in_addr src,
/* implicit transport address */
if (transport_addr.s_addr == INADDR_ANY)
- transport_addr.s_addr = src.s_addr;
+ transport_addr = src;
if (bad_ip_addr(transport_addr)) {
log_debug("%s: lsr-id %s: invalid transport address %s",
__func__, inet_ntoa(lsr_id), inet_ntoa(transport_addr));
diff --git a/usr.sbin/ldpd/interface.c b/usr.sbin/ldpd/interface.c
index 2d3786460b8..c80ecc77464 100644
--- a/usr.sbin/ldpd/interface.c
+++ b/usr.sbin/ldpd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.36 2016/05/23 17:43:42 renato Exp $ */
+/* $OpenBSD: interface.c,v 1.37 2016/05/23 18:28:22 renato Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -121,9 +121,9 @@ if_addr_new(struct kaddr *ka)
if ((if_addr = calloc(1, sizeof(*if_addr))) == NULL)
fatal(__func__);
- if_addr->addr.s_addr = ka->addr.s_addr;
- if_addr->mask.s_addr = ka->mask.s_addr;
- if_addr->dstbrd.s_addr = ka->dstbrd.s_addr;
+ if_addr->addr = ka->addr;
+ if_addr->mask = ka->mask;
+ if_addr->dstbrd = ka->dstbrd;
return (if_addr);
}
@@ -337,8 +337,8 @@ if_join_group(struct iface *iface, struct in_addr *addr)
inet_ntoa(*addr));
if_addr = LIST_FIRST(&iface->addr_list);
- mreq.imr_multiaddr.s_addr = addr->s_addr;
- mreq.imr_interface.s_addr = if_addr->addr.s_addr;
+ mreq.imr_multiaddr = *addr;
+ mreq.imr_interface = if_addr->addr;
if (setsockopt(global.ldp_disc_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(void *)&mreq, sizeof(mreq)) < 0) {
@@ -362,8 +362,8 @@ if_leave_group(struct iface *iface, struct in_addr *addr)
if (!if_addr)
return (0);
- mreq.imr_multiaddr.s_addr = addr->s_addr;
- mreq.imr_interface.s_addr = if_addr->addr.s_addr;
+ mreq.imr_multiaddr = *addr;
+ mreq.imr_interface = if_addr->addr;
if (setsockopt(global.ldp_disc_socket, IPPROTO_IP, IP_DROP_MEMBERSHIP,
(void *)&mreq, sizeof(mreq)) < 0) {
diff --git a/usr.sbin/ldpd/kroute.c b/usr.sbin/ldpd/kroute.c
index b2744443121..839fbb08acb 100644
--- a/usr.sbin/ldpd/kroute.c
+++ b/usr.sbin/ldpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.53 2016/05/23 17:43:42 renato Exp $ */
+/* $OpenBSD: kroute.c,v 1.54 2016/05/23 18:28:22 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -621,7 +621,7 @@ kroute_insert(struct kroute *kr)
kp = calloc(1, sizeof(struct kroute_prefix));
if (kp == NULL)
fatal(__func__);
- kp->prefix.s_addr = kr->prefix.s_addr;
+ kp->prefix = kr->prefix;
kp->prefixlen = kr->prefixlen;
TAILQ_INIT(&kp->priorities);
RB_INSERT(kroute_tree, &krt, kp);
@@ -655,7 +655,7 @@ done:
if (kn == NULL)
fatal(__func__);
kn->kprio = kprio;
- memcpy(&kn->r, kr, sizeof(struct kroute));
+ kn->r = *kr;
TAILQ_INSERT_TAIL(&kprio->nexthops, kn, entry);
}
@@ -968,13 +968,13 @@ if_newaddr(unsigned short ifindex, struct sockaddr_in *ifa,
if ((ka = calloc(1, sizeof(struct kif_addr))) == NULL)
fatal(__func__);
ka->addr.ifindex = ifindex;
- ka->addr.addr.s_addr = ifa->sin_addr.s_addr;
+ ka->addr.addr = ifa->sin_addr;
if (mask)
- ka->addr.mask.s_addr = mask->sin_addr.s_addr;
+ ka->addr.mask = mask->sin_addr;
else
ka->addr.mask.s_addr = INADDR_NONE;
if (brd)
- ka->addr.dstbrd.s_addr = brd->sin_addr.s_addr;
+ ka->addr.dstbrd = brd->sin_addr;
else
ka->addr.dstbrd.s_addr = INADDR_NONE;
@@ -1088,7 +1088,7 @@ send_rtmsg(int fd, int action, struct kroute *kroute, uint32_t family)
memset(&dst, 0, sizeof(dst));
dst.sin_len = sizeof(dst);
dst.sin_family = AF_INET;
- dst.sin_addr.s_addr = kroute->prefix.s_addr;
+ dst.sin_addr = kroute->prefix;
/* adjust header */
hdr.rtm_addrs |= RTA_DST;
hdr.rtm_msglen += sizeof(dst);
@@ -1100,7 +1100,7 @@ send_rtmsg(int fd, int action, struct kroute *kroute, uint32_t family)
memset(&nexthop, 0, sizeof(nexthop));
nexthop.sin_len = sizeof(nexthop);
nexthop.sin_family = AF_INET;
- nexthop.sin_addr.s_addr = kroute->nexthop.s_addr;
+ nexthop.sin_addr = kroute->nexthop;
/* adjust header */
hdr.rtm_flags |= RTF_GATEWAY;
hdr.rtm_addrs |= RTA_GATEWAY;
@@ -1330,8 +1330,7 @@ rtmsg_process(char *buf, size_t len)
switch (sa->sa_family) {
case AF_INET:
- prefix.s_addr =
- ((struct sockaddr_in *)sa)->sin_addr.s_addr;
+ prefix = ((struct sockaddr_in *)sa)->sin_addr;
sa_in = (struct sockaddr_in *)
rti_info[RTAX_NETMASK];
if (sa_in != NULL) {
@@ -1364,8 +1363,8 @@ rtmsg_process(char *buf, size_t len)
flags |= F_CONNECTED;
break;
}
- nexthop.s_addr = ((struct
- sockaddr_in *)sa)->sin_addr.s_addr;
+ nexthop = ((struct
+ sockaddr_in *)sa)->sin_addr;
break;
case AF_LINK:
/*
@@ -1419,9 +1418,9 @@ rtmsg_process(char *buf, size_t len)
break;
memset(&kr, 0, sizeof(kr));
- kr.prefix.s_addr = prefix.s_addr;
+ kr.prefix = prefix;
kr.prefixlen = prefixlen;
- kr.nexthop.s_addr = nexthop.s_addr;
+ kr.nexthop = nexthop;
kr.flags = flags;
kr.ifindex = ifindex;
kr.priority = prio;
@@ -1492,7 +1491,7 @@ kmpw_set(struct kpw *kpw)
if (kif->kpw == NULL)
kif->kpw = malloc(sizeof(*kif->kpw));
- memcpy(kif->kpw, kpw, sizeof(*kif->kpw));
+ *kif->kpw = *kpw;
kmpw_install(kif->k.ifname, kpw);
}
@@ -1545,7 +1544,7 @@ kmpw_install(const char *ifname, struct kpw *kpw)
sin = (struct sockaddr_in *) &imr.imr_nexthop;
sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = kpw->nexthop.s_addr;
+ sin->sin_addr = kpw->nexthop;
sin->sin_len = sizeof(struct sockaddr_in);
imr.imr_lshim.shim_label = kpw->local_label;
diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c
index 6a86748e2b4..29e3dc9f720 100644
--- a/usr.sbin/ldpd/lde.c
+++ b/usr.sbin/ldpd/lde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde.c,v 1.49 2016/05/23 17:43:42 renato Exp $ */
+/* $OpenBSD: lde.c,v 1.50 2016/05/23 18:28:22 renato Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -446,7 +446,7 @@ lde_dispatch_parent(int fd, short event, void *bula)
memcpy(&kr, imsg.data, sizeof(kr));
fec.type = FEC_TYPE_IPV4;
- fec.u.ipv4.prefix.s_addr = kr.prefix.s_addr;
+ fec.u.ipv4.prefix = kr.prefix;
fec.u.ipv4.prefixlen = kr.prefixlen;
lde_kernel_insert(&fec, kr.nexthop,
kr.flags & F_CONNECTED, NULL);
@@ -459,7 +459,7 @@ lde_dispatch_parent(int fd, short event, void *bula)
memcpy(&kr, imsg.data, sizeof(kr));
fec.type = FEC_TYPE_IPV4;
- fec.u.ipv4.prefix.s_addr = kr.prefix.s_addr;
+ fec.u.ipv4.prefix = kr.prefix;
fec.u.ipv4.prefixlen = kr.prefixlen;
lde_kernel_remove(&fec, kr.nexthop);
break;
@@ -564,10 +564,10 @@ lde_send_change_klabel(struct fec_node *fn, struct fec_nh *fnh)
switch (fn->fec.type) {
case FEC_TYPE_IPV4:
memset(&kr, 0, sizeof(kr));
- kr.prefix.s_addr = fn->fec.u.ipv4.prefix.s_addr;
+ kr.prefix = fn->fec.u.ipv4.prefix;
kr.prefixlen = fn->fec.u.ipv4.prefixlen;
kr.local_label = fn->local_label;
- kr.nexthop.s_addr = fnh->nexthop.s_addr;
+ kr.nexthop = fnh->nexthop;
kr.remote_label = fnh->remote_label;
lde_imsg_compose_parent(IMSG_KLABEL_CHANGE, 0, &kr,
@@ -588,7 +588,7 @@ lde_send_change_klabel(struct fec_node *fn, struct fec_nh *fnh)
memset(&kpw, 0, sizeof(kpw));
kpw.ifindex = pw->ifindex;
kpw.pw_type = fn->fec.u.pwid.type;
- kpw.nexthop.s_addr = fnh->nexthop.s_addr;
+ kpw.nexthop = fnh->nexthop;
kpw.local_label = fn->local_label;
kpw.remote_label = fnh->remote_label;
kpw.flags = pw->flags;
@@ -609,10 +609,10 @@ lde_send_delete_klabel(struct fec_node *fn, struct fec_nh *fnh)
switch (fn->fec.type) {
case FEC_TYPE_IPV4:
memset(&kr, 0, sizeof(kr));
- kr.prefix.s_addr = fn->fec.u.ipv4.prefix.s_addr;
+ kr.prefix = fn->fec.u.ipv4.prefix;
kr.prefixlen = fn->fec.u.ipv4.prefixlen;
kr.local_label = fn->local_label;
- kr.nexthop.s_addr = fnh->nexthop.s_addr;
+ kr.nexthop = fnh->nexthop;
kr.remote_label = fnh->remote_label;
lde_imsg_compose_parent(IMSG_KLABEL_DELETE, 0, &kr,
@@ -630,7 +630,7 @@ lde_send_delete_klabel(struct fec_node *fn, struct fec_nh *fnh)
memset(&kpw, 0, sizeof(kpw));
kpw.ifindex = pw->ifindex;
kpw.pw_type = fn->fec.u.pwid.type;
- kpw.nexthop.s_addr = fnh->nexthop.s_addr;
+ kpw.nexthop = fnh->nexthop;
kpw.local_label = fn->local_label;
kpw.remote_label = fnh->remote_label;
kpw.flags = pw->flags;
@@ -670,7 +670,7 @@ lde_map2fec(struct map *map, struct in_addr lsr_id, struct fec *fec)
switch (map->type) {
case MAP_TYPE_PREFIX:
fec->type = FEC_TYPE_IPV4;
- fec->u.ipv4.prefix.s_addr = map->fec.ipv4.prefix.s_addr;
+ fec->u.ipv4.prefix = map->fec.ipv4.prefix;
fec->u.ipv4.prefixlen = map->fec.ipv4.prefixlen;
break;
case MAP_TYPE_PWID:
@@ -737,7 +737,7 @@ lde_send_labelmapping(struct lde_nbr *ln, struct fec_node *fn, int single)
me = (struct lde_map *)fec_find(&ln->sent_map, &fn->fec);
if (me == NULL)
me = lde_map_add(ln, fn, 1);
- memcpy(&me->map, &map, sizeof(map));
+ me->map = map;
}
void
@@ -857,7 +857,7 @@ lde_nbr_new(uint32_t peerid, struct in_addr *id)
if ((ln = calloc(1, sizeof(*ln))) == NULL)
fatal(__func__);
- ln->id.s_addr = id->s_addr;
+ ln->id = *id;
ln->peerid = peerid;
fec_init(&ln->recv_map);
fec_init(&ln->sent_map);
@@ -1109,7 +1109,7 @@ lde_address_add(struct lde_nbr *ln, struct in_addr *addr)
if ((address = calloc(1, sizeof(*address))) == NULL)
fatal(__func__);
- address->addr.s_addr = addr->s_addr;
+ address->addr = *addr;
TAILQ_INSERT_TAIL(&ln->addr_list, address, entry);
diff --git a/usr.sbin/ldpd/lde_lib.c b/usr.sbin/ldpd/lde_lib.c
index 49fcde639fd..03d42e99386 100644
--- a/usr.sbin/ldpd/lde_lib.c
+++ b/usr.sbin/ldpd/lde_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde_lib.c,v 1.49 2016/05/23 17:43:42 renato Exp $ */
+/* $OpenBSD: lde_lib.c,v 1.50 2016/05/23 18:28:22 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -242,7 +242,7 @@ fec_add(struct fec *fec)
if (fn == NULL)
fatal(__func__);
- memcpy(&fn->fec, fec, sizeof(fn->fec));
+ fn->fec = *fec;
fn->local_label = NO_LABEL;
LIST_INIT(&fn->upstream);
LIST_INIT(&fn->downstream);
@@ -275,7 +275,7 @@ fec_nh_add(struct fec_node *fn, struct in_addr nexthop)
if (fnh == NULL)
fatal(__func__);
- fnh->nexthop.s_addr = nexthop.s_addr;
+ fnh->nexthop = nexthop;
fnh->remote_label = NO_LABEL;
LIST_INSERT_HEAD(&fn->nexthops, fnh, entry);
@@ -494,7 +494,7 @@ lde_check_mapping(struct map *map, struct lde_nbr *ln)
/* LMp.13 & LMp.16: Record the mapping from this peer */
if (me == NULL)
me = lde_map_add(ln, fn, 0);
- memcpy(&me->map, map, sizeof(*map));
+ me->map = *map;
if (msgsource == 0)
/* LMp.13: just return since we use liberal lbl retention */
diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c
index dbf786da94f..3e1132a03de 100644
--- a/usr.sbin/ldpd/ldpd.c
+++ b/usr.sbin/ldpd/ldpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.c,v 1.37 2016/05/23 17:43:42 renato Exp $ */
+/* $OpenBSD: ldpd.c,v 1.38 2016/05/23 18:28:22 renato Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -635,7 +635,7 @@ merge_global(struct ldpd_conf *conf, struct ldpd_conf *xconf)
conf->keepalive = xconf->keepalive;
conf->thello_holdtime = xconf->thello_holdtime;
conf->thello_interval = xconf->thello_interval;
- conf->trans_addr.s_addr = xconf->trans_addr.s_addr;
+ conf->trans_addr = xconf->trans_addr;
/* update flags */
if ((conf->flags & F_LDPD_EXPNULL) !=
@@ -955,7 +955,7 @@ config_clear(struct ldpd_conf *conf)
/* merge current config with an empty config */
xconf = malloc(sizeof(*xconf));
- memcpy(xconf, conf, sizeof(*xconf));
+ *xconf = *conf;
LIST_INIT(&xconf->iface_list);
LIST_INIT(&xconf->tnbr_list);
LIST_INIT(&xconf->nbrp_list);
diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c
index 6b7477b7279..57815167123 100644
--- a/usr.sbin/ldpd/neighbor.c
+++ b/usr.sbin/ldpd/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.65 2016/05/23 17:43:42 renato Exp $ */
+/* $OpenBSD: neighbor.c,v 1.66 2016/05/23 18:28:22 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -233,9 +233,9 @@ nbr_new(struct in_addr id, struct in_addr addr)
LIST_INIT(&nbr->adj_list);
nbr->state = NBR_STA_PRESENT;
- nbr->id.s_addr = id.s_addr;
- nbr->laddr.s_addr = leconf->trans_addr.s_addr;
- nbr->raddr.s_addr = addr.s_addr;
+ nbr->id = id;
+ nbr->laddr = leconf->trans_addr;
+ nbr->raddr = addr;
nbr->peerid = 0;
if (RB_INSERT(nbr_id_head, &nbrs_by_id, nbr) != NULL)
@@ -534,7 +534,7 @@ nbr_establish_connection(struct nbr *nbr)
memset(&local_sa, 0, sizeof(local_sa));
local_sa.sin_family = AF_INET;
local_sa.sin_port = htons(0);
- local_sa.sin_addr.s_addr = nbr->laddr.s_addr;
+ local_sa.sin_addr = nbr->laddr;
if (bind(nbr->fd, (struct sockaddr *) &local_sa,
sizeof(struct sockaddr_in)) == -1) {
@@ -547,7 +547,7 @@ nbr_establish_connection(struct nbr *nbr)
memset(&remote_sa, 0, sizeof(remote_sa));
remote_sa.sin_family = AF_INET;
remote_sa.sin_port = htons(LDP_PORT);
- remote_sa.sin_addr.s_addr = nbr->raddr.s_addr;
+ remote_sa.sin_addr = nbr->raddr;
/*
* Send an extra hello to guarantee that the remote peer has formed
@@ -640,8 +640,8 @@ nbr_to_ctl(struct nbr *nbr)
static struct ctl_nbr nctl;
struct timeval now;
- memcpy(&nctl.id, &nbr->id, sizeof(nctl.id));
- memcpy(&nctl.addr, &nbr->raddr, sizeof(nctl.addr));
+ nctl.id = nbr->id;
+ nctl.addr = nbr->raddr;
nctl.nbr_state = nbr->state;
gettimeofday(&now, NULL);
diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y
index a53b9a88868..15d524156d5 100644
--- a/usr.sbin/ldpd/parse.y
+++ b/usr.sbin/ldpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.44 2016/05/23 17:43:42 renato Exp $ */
+/* $OpenBSD: parse.y,v 1.45 2016/05/23 18:28:22 renato Exp $ */
/*
* Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org>
@@ -402,7 +402,7 @@ pseudowire : PSEUDOWIRE STRING {
YYERROR;
LIST_INSERT_HEAD(&l2vpn->pw_list, pw, entry);
- memcpy(&pwdefs, defs, sizeof(pwdefs));
+ pwdefs = *defs;
defs = &pwdefs;
} pw_block {
struct l2vpn *l;
@@ -547,7 +547,7 @@ interface : INTERFACE STRING {
}
LIST_INSERT_HEAD(&conf->iface_list, iface, entry);
- memcpy(&ifacedefs, defs, sizeof(ifacedefs));
+ ifacedefs = *defs;
defs = &ifacedefs;
} interface_block {
iface->hello_holdtime = defs->lhello_holdtime;
@@ -589,7 +589,7 @@ tneighbor : TNEIGHBOR STRING {
tnbr->flags |= F_TNBR_CONFIGURED;
LIST_INSERT_HEAD(&conf->tnbr_list, tnbr, entry);
- memcpy(&tnbrdefs, defs, sizeof(tnbrdefs));
+ tnbrdefs = *defs;
defs = &tnbrdefs;
} tneighbor_block {
tnbr->hello_holdtime = defs->thello_holdtime;
@@ -1108,7 +1108,7 @@ parse_config(char *filename)
if (conf->rtr_id.s_addr == 0)
conf->rtr_id.s_addr = get_rtr_id();
if (conf->trans_addr.s_addr == 0)
- conf->trans_addr.s_addr = conf->rtr_id.s_addr;
+ conf->trans_addr = conf->rtr_id;
return (conf);
}
@@ -1381,7 +1381,7 @@ host(const char *s, struct in_addr *addr, struct in_addr *mask)
return (0);
}
- addr->s_addr = ina.s_addr;
+ *addr = ina;
mask->s_addr = prefixlen2mask(bits);
return (1);
diff --git a/usr.sbin/ldpd/pfkey.c b/usr.sbin/ldpd/pfkey.c
index b36f7c2cf06..e1d470b6afa 100644
--- a/usr.sbin/ldpd/pfkey.c
+++ b/usr.sbin/ldpd/pfkey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkey.c,v 1.6 2016/05/23 17:43:42 renato Exp $ */
+/* $OpenBSD: pfkey.c,v 1.7 2016/05/23 18:28:22 renato Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -62,7 +62,7 @@ addr2sa(struct in_addr *addr)
memset(&ss, 0, sizeof(ss));
sa_in->sin_family = AF_INET;
sa_in->sin_len = sizeof(struct sockaddr_in);
- sa_in->sin_addr.s_addr = addr->s_addr;
+ sa_in->sin_addr = *addr;
sa_in->sin_port = htons(0);
return ((struct sockaddr *)&ss);
@@ -263,7 +263,7 @@ pfkey_read(int sd, struct sadb_msg *h)
if (hdr.sadb_msg_seq == sadb_msg_seq &&
hdr.sadb_msg_pid == pid) {
if (h)
- memcpy(h, &hdr, sizeof(hdr));
+ *h = hdr;
return (0);
}