Commit 63f53d40 authored by Philip Withnall's avatar Philip Withnall

agent: Fix a utility function being defined unnecessarily

sockaddr_to_string() is not needed on UNIX when compiling without
HAVE_GETIFADDRS. This fixes a compiler warning in that case.
parent 238293c2
......@@ -71,6 +71,34 @@
#include <net/if.h>
#include <arpa/inet.h>
#endif /* G_OS_UNIX */
#if (defined(G_OS_UNIX) && defined(HAVE_GETIFADDRS)) || defined(G_OS_WIN32)
/* Works on both UNIX and Windows. Magic! */
static gchar *
sockaddr_to_string (const struct sockaddr *addr)
{
char addr_as_string[INET6_ADDRSTRLEN+1];
size_t addr_len;
switch (addr->sa_family) {
case AF_INET: addr_len = sizeof (struct sockaddr_in); break;
case AF_INET6: addr_len = sizeof (struct sockaddr_in6); break;
default: return NULL;
}
if (getnameinfo (addr, addr_len,
addr_as_string, sizeof (addr_as_string), NULL, 0,
NI_NUMERICHOST) != 0) {
return NULL;
}
return g_strdup (addr_as_string);
}
#endif
#ifdef G_OS_UNIX
#ifdef HAVE_GETIFADDRS
GList *
......@@ -209,9 +237,6 @@ add_ip_to_list (GList *list, gchar *ip, gboolean append)
#ifdef HAVE_GETIFADDRS
static gchar *
sockaddr_to_string (const struct sockaddr *addr);
GList *
nice_interfaces_get_local_ips (gboolean include_loopback)
{
......@@ -461,9 +486,6 @@ GList * nice_interfaces_get_local_interfaces (void)
return ret;
}
static gchar *
sockaddr_to_string (const struct sockaddr *addr);
GList * nice_interfaces_get_local_ips (gboolean include_loopback)
{
IP_ADAPTER_ADDRESSES *addresses = NULL, *a;
......@@ -638,25 +660,3 @@ gchar * nice_interfaces_get_ip_for_interface (gchar *interface_name)
#error Can not use this method for retreiving ip list from OS other than unix or windows
#endif /* G_OS_WIN32 */
#endif /* G_OS_UNIX */
/* Works on both UNIX and Windows. Magic! */
static gchar *
sockaddr_to_string (const struct sockaddr *addr)
{
char addr_as_string[INET6_ADDRSTRLEN+1];
size_t addr_len;
switch (addr->sa_family) {
case AF_INET: addr_len = sizeof (struct sockaddr_in); break;
case AF_INET6: addr_len = sizeof (struct sockaddr_in6); break;
default: return NULL;
}
if (getnameinfo (addr, addr_len,
addr_as_string, sizeof (addr_as_string), NULL, 0,
NI_NUMERICHOST) != 0) {
return NULL;
}
return g_strdup (addr_as_string);
}
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