mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04: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
1 changed files with 5 additions and 2 deletions
|
|
@ -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