summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd/neighbor.c
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 /usr.sbin/ldpd/neighbor.c
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.
Diffstat (limited to 'usr.sbin/ldpd/neighbor.c')
-rw-r--r--usr.sbin/ldpd/neighbor.c16
1 files changed, 8 insertions, 8 deletions
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);