Set sockaddr family on ifreq instead of casted familiy specific sockaddr
Fixes a strict-aliasing rule compiler warning with older gcc.
This commit is contained in:
parent
d830174e3c
commit
82c884c015
1 changed files with 2 additions and 2 deletions
|
@ -88,7 +88,6 @@ static void set_netmask(struct ifreq *ifr, int family, u_int8_t netmask)
|
|||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in *addr = (struct sockaddr_in*)&ifr->ifr_addr;
|
||||
addr->sin_family = AF_INET;
|
||||
target = (char*)&addr->sin_addr;
|
||||
len = 4;
|
||||
break;
|
||||
|
@ -96,7 +95,6 @@ static void set_netmask(struct ifreq *ifr, int family, u_int8_t netmask)
|
|||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6 *addr = (struct sockaddr_in6*)&ifr->ifr_addr;
|
||||
addr->sin6_family = AF_INET6;
|
||||
target = (char*)&addr->sin6_addr;
|
||||
len = 16;
|
||||
break;
|
||||
|
@ -105,6 +103,8 @@ static void set_netmask(struct ifreq *ifr, int family, u_int8_t netmask)
|
|||
return;
|
||||
}
|
||||
|
||||
ifr->ifr_addr.sa_family = family;
|
||||
|
||||
bytes = (netmask + 7) / 8;
|
||||
bits = (bytes * 8) - netmask;
|
||||
|
||||
|
|
Loading…
Reference in a new issue