diff options
author | ngie <ngie@FreeBSD.org> | 2016-05-15 03:36:19 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2016-05-15 03:36:19 +0000 |
commit | ed17cd41cad8a215e390098446e52c0c72bbb48f (patch) | |
tree | 48041c0c1208baa9de278aafabdf61419c6bf40c /contrib/bsnmp | |
parent | a0640b82623c9559706fb4d24338bb39f6ed5d53 (diff) | |
download | FreeBSD-src-ed17cd41cad8a215e390098446e52c0c72bbb48f.zip FreeBSD-src-ed17cd41cad8a215e390098446e52c0c72bbb48f.tar.gz |
Fix -Wcast-align warnings
Use memcpy instead of using direct assignment of void* pointers with
CMSG_DATA(..), which changes alignment
MFC after: 3 weeks
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'contrib/bsnmp')
-rw-r--r-- | contrib/bsnmp/snmpd/main.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/bsnmp/snmpd/main.c b/contrib/bsnmp/snmpd/main.c index ea87127..06df31d 100644 --- a/contrib/bsnmp/snmpd/main.c +++ b/contrib/bsnmp/snmpd/main.c @@ -1169,7 +1169,7 @@ recv_dgram(struct port_input *pi, struct in_addr *laddr) memcpy(laddr, CMSG_DATA(cmsg), sizeof(struct in_addr)); if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDS) - cred = (struct sockcred *)CMSG_DATA(cmsg); + memcpy(cred, CMSG_DATA(cmsg), sizeof(struct sockcred)); } if (pi->cred) @@ -1207,7 +1207,7 @@ snmpd_input(struct port_input *pi, struct tport *tport) ret = recv_stream(pi); } else { - struct in_addr *laddr; + struct in_addr laddr; memset(cbuf, 0, CMSG_SPACE(sizeof(struct in_addr))); msg.msg_control = cbuf; @@ -1216,11 +1216,11 @@ snmpd_input(struct port_input *pi, struct tport *tport) cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in_addr)); cmsgp->cmsg_level = IPPROTO_IP; cmsgp->cmsg_type = IP_SENDSRCADDR; - laddr = (struct in_addr *)CMSG_DATA(cmsgp); + memcpy(&laddr, CMSG_DATA(cmsgp), sizeof(struct in_addr)); - ret = recv_dgram(pi, laddr); + ret = recv_dgram(pi, &laddr); - if (laddr->s_addr == 0) { + if (laddr.s_addr == 0) { msg.msg_control = NULL; msg.msg_controllen = 0; } |