[Listener] Fix strict-aliasing rule warning

This commit is contained in:
Matteo Cypriani 2010-10-20 17:20:47 +02:00
parent ed7828a339
commit 3c0f74fcb3
1 changed files with 4 additions and 4 deletions

View File

@ -799,6 +799,7 @@ void get_ip_addr(char *eth, char ip[16])
struct ifreq ifr; struct ifreq ifr;
int sockfd ; int sockfd ;
struct sockaddr_in sa ; struct sockaddr_in sa ;
struct in_addr ip_addr ;
sockfd = socket(AF_INET, SOCK_DGRAM, 0) ; sockfd = socket(AF_INET, SOCK_DGRAM, 0) ;
if(sockfd < 0) if(sockfd < 0)
@ -812,10 +813,9 @@ void get_ip_addr(char *eth, char ip[16])
if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0) if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0)
return ; return ;
strncpy(ip, memcpy(&ip_addr, &ifr.ifr_addr.sa_data[sizeof(sa.sin_port)],
inet_ntoa(*(struct in_addr *) sizeof(ip_addr)) ;
&ifr.ifr_addr.sa_data[sizeof(sa.sin_port)]), strncpy(ip, inet_ntoa(ip_addr), 16) ;
16) ;
} }