mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-16 06:52:27 +00:00
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)); ^~~~~~~~~~~~~~~~~ MFC after: 3 days
This commit is contained in:
parent
172ae88fec
commit
a94c074d6a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=311530
|
@ -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++);
|
||||
|
|
Loading…
Reference in a new issue