diff options
author | dim <dim@FreeBSD.org> | 2017-01-11 20:29:58 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2017-01-11 20:29:58 +0000 |
commit | 0c25c64ddbf4c0ecfbbedd0658bbe1de1652c287 (patch) | |
tree | 5485d9fc5734aca74dd7f3748076093bb6f331a1 /sbin/ping | |
parent | 6cfd0dae6097edf71fdf60038c4a1dbed9bbec5b (diff) | |
download | FreeBSD-src-0c25c64ddbf4c0ecfbbedd0658bbe1de1652c287.zip FreeBSD-src-0c25c64ddbf4c0ecfbbedd0658bbe1de1652c287.tar.gz |
MFC r311530:
Fix clang 4.0.0 warnings about taking the address of a packed member of
struct ip in ping(8):
sbin/ping/ping.c:1684:53: error: taking address of packed member
'ip_src' of class or structure 'ip' may result in an unaligned pointer
value [-Werror,-Waddress-of-packed-member]
(void)printf(" %s ", inet_ntoa(*(struct in_addr *)&ip->ip_src.s_addr));
^~~~~~~~~~~~~~~~~
sbin/ping/ping.c:1685:53: error: taking address of packed member
'ip_dst' of class or structure 'ip' may result in an unaligned pointer
value [-Werror,-Waddress-of-packed-member]
(void)printf(" %s ", inet_ntoa(*(struct in_addr *)&ip->ip_dst.s_addr));
^~~~~~~~~~~~~~~~~
Diffstat (limited to 'sbin/ping')
-rw-r--r-- | sbin/ping/ping.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index db78ef6..ab4764a 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1666,6 +1666,7 @@ pr_icmph(struct icmp *icp) static void pr_iph(struct ip *ip) { + struct in_addr ina; u_char *cp; int hlen; @@ -1681,8 +1682,10 @@ pr_iph(struct ip *ip) (u_long) ntohl(ip->ip_off) & 0x1fff); (void)printf(" %02x %02x %04x", ip->ip_ttl, ip->ip_p, ntohs(ip->ip_sum)); - (void)printf(" %s ", inet_ntoa(*(struct in_addr *)&ip->ip_src.s_addr)); - (void)printf(" %s ", inet_ntoa(*(struct in_addr *)&ip->ip_dst.s_addr)); + memcpy(&ina, &ip->ip_src.s_addr, sizeof ina); + (void)printf(" %s ", inet_ntoa(ina)); + memcpy(&ina, &ip->ip_dst.s_addr, sizeof ina); + (void)printf(" %s ", inet_ntoa(ina)); /* dump any option bytes */ while (hlen-- > 20) { (void)printf("%02x", *cp++); |