Commit db9c2ca6 authored by Olivier Crête's avatar Olivier Crête 👻 Committed by Olivier Crête
Browse files

interfaces: Use union for sockaddr/sockaddr_in

This makes clang happy
Fixes #100
parent ac3f7b5e
Pipeline #142550 failed with stages
in 13 minutes and 16 seconds
...@@ -269,7 +269,11 @@ get_local_ips_ioctl (gboolean include_loopback) ...@@ -269,7 +269,11 @@ get_local_ips_ioctl (gboolean include_loopback)
gint size = 0; gint size = 0;
struct ifreq *ifr; struct ifreq *ifr;
struct ifconf ifc; struct ifconf ifc;
struct sockaddr_in *sa; union {
struct sockaddr_in *sin;
struct sockaddr *sa;
} sa;
GList *loopbacks = NULL; GList *loopbacks = NULL;
#ifdef IGNORED_IFACE_PREFIX #ifdef IGNORED_IFACE_PREFIX
const gchar **prefix; const gchar **prefix;
...@@ -324,12 +328,12 @@ get_local_ips_ioctl (gboolean include_loopback) ...@@ -324,12 +328,12 @@ get_local_ips_ioctl (gboolean include_loopback)
if ((ifr->ifr_flags & IFF_RUNNING) == 0) if ((ifr->ifr_flags & IFF_RUNNING) == 0)
continue; continue;
sa = (struct sockaddr_in *) &ifr->ifr_addr; sa.sa = &ifr->ifr_addr;
nice_debug ("Interface: %s", ifr->ifr_name); nice_debug ("Interface: %s", ifr->ifr_name);
nice_debug ("IP Address: %s", inet_ntoa (sa->sin_addr)); nice_debug ("IP Address: %s", inet_ntoa (sa.sin->sin_addr));
if ((ifr->ifr_flags & IFF_LOOPBACK) == IFF_LOOPBACK){ if ((ifr->ifr_flags & IFF_LOOPBACK) == IFF_LOOPBACK){
if (include_loopback) if (include_loopback)
loopbacks = add_ip_to_list (loopbacks, g_strdup (inet_ntoa (sa->sin_addr)), TRUE); loopbacks = add_ip_to_list (loopbacks, g_strdup (inet_ntoa (sa.sin->sin_addr)), TRUE);
else else
nice_debug ("Ignoring loopback interface"); nice_debug ("Ignoring loopback interface");
continue; continue;
...@@ -350,10 +354,10 @@ get_local_ips_ioctl (gboolean include_loopback) ...@@ -350,10 +354,10 @@ get_local_ips_ioctl (gboolean include_loopback)
continue; continue;
#endif #endif
if (nice_interfaces_is_private_ip ((struct sockaddr *) sa)) { if (nice_interfaces_is_private_ip (sa.sa)) {
ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa->sin_addr)), TRUE); ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa.sin->sin_addr)), TRUE);
} else { } else {
ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa->sin_addr)), FALSE); ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa.sin->sin_addr)), FALSE);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment