From 9f8ed2802da6b48cb71377da84a83db04d3530b8 Mon Sep 17 00:00:00 2001 From: Roop <40358733+sairoop-elear@users.noreply.github.com> Date: Fri, 7 Feb 2020 11:01:45 +0530 Subject: [PATCH] Fix android (Android 6 or before) compilation issue around getifaddr --- configure.ac | 2 +- src/net.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 4028613f..00e47fae 100644 --- a/configure.ac +++ b/configure.ac @@ -134,7 +134,7 @@ AC_CHECK_TYPES([struct sockaddr_storage], ,AC_MSG_ERROR([System must support str dnl Checks for library functions. AC_TYPE_SIGNAL -AC_CHECK_FUNCS([asprintf fchmod fork gettimeofday random select setns strdup usleep getifaddrs], +AC_CHECK_FUNCS([asprintf fchmod fork gettimeofday random select setns strdup usleep getifaddrs freeifaddrs], [], [], [#include "$srcdir/src/have.h"] ) diff --git a/src/net.c b/src/net.c index 7c600534..95790ac1 100644 --- a/src/net.c +++ b/src/net.c @@ -639,7 +639,7 @@ void retry(meshlink_handle_t *mesh) { }); } -#ifdef HAVE_IFADDRS_H +#if defined(HAVE_IFADDRS_H) && defined(HAVE_GETIFADDRS) && defined(HAVE_FREEIFADDRS) struct ifaddrs *ifa = NULL; getifaddrs(&ifa); #endif @@ -655,7 +655,7 @@ void retry(meshlink_handle_t *mesh) { c->last_ping_time = 0; } -#ifdef HAVE_IFADDRS_H +#if defined(HAVE_IFADDRS_H) && defined(HAVE_GETIFADDRS) && defined(HAVE_FREEIFADDRS) if(!ifa) { continue; @@ -686,7 +686,7 @@ void retry(meshlink_handle_t *mesh) { #endif } -#ifdef HAVE_IFADDRS_H +#if defined(HAVE_IFADDRS_H) && defined(HAVE_GETIFADDRS) && defined(HAVE_FREEIFADDRS) if(ifa) { freeifaddrs(ifa); -- 2.39.2