Author: ngie Date: Sun May 15 03:36:19 2016 New Revision: 299830 URL: https://svnweb.freebsd.org/changeset/base/299830
Log: 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 Modified: head/contrib/bsnmp/snmpd/main.c Modified: head/contrib/bsnmp/snmpd/main.c ============================================================================== --- head/contrib/bsnmp/snmpd/main.c Sun May 15 03:22:13 2016 (r299829) +++ head/contrib/bsnmp/snmpd/main.c Sun May 15 03:36:19 2016 (r299830) @@ -1169,7 +1169,7 @@ recv_dgram(struct port_input *pi, struct 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, struc 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, struc 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; } _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"