From ee773bbc8a7760671d68339772cae44c56f0e24f Mon Sep 17 00:00:00 2001 From: Fred Morcos Date: Wed, 16 Aug 2023 14:14:21 +0200 Subject: [PATCH] Consistency: Use #ifdef instead of #if in iputils.cc --- pdns/iputils.cc | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/pdns/iputils.cc b/pdns/iputils.cc index 31ac2a9773..2eda93507c 100644 --- a/pdns/iputils.cc +++ b/pdns/iputils.cc @@ -28,7 +28,7 @@ #include #include -#if HAVE_GETIFADDRS +#ifdef HAVE_GETIFADDRS #include #endif @@ -540,7 +540,7 @@ void setSocketSendBuffer(int fd, uint32_t size) std::set getListOfNetworkInterfaces() { std::set result; -#if HAVE_GETIFADDRS +#ifdef HAVE_GETIFADDRS struct ifaddrs *ifaddr; if (getifaddrs(&ifaddr) == -1) { return result; @@ -558,11 +558,11 @@ std::set getListOfNetworkInterfaces() return result; } +#ifdef HAVE_GETIFADDRS std::vector getListOfAddressesOfNetworkInterface(const std::string& itf) { std::vector result; -#if HAVE_GETIFADDRS - struct ifaddrs *ifaddr; + struct ifaddrs *ifaddr = nullptr; if (getifaddrs(&ifaddr) == -1) { return result; } @@ -586,11 +586,17 @@ std::vector getListOfAddressesOfNetworkInterface(const std::string } freeifaddrs(ifaddr); -#endif return result; } +#else +std::vector getListOfAddressesOfNetworkInterface(const std::string& /* itf */) +{ + std::vector result; + return result; +} +#endif // HAVE_GETIFADDRS -#if HAVE_GETIFADDRS +#ifdef HAVE_GETIFADDRS static uint8_t convertNetmaskToBits(const uint8_t* mask, socklen_t len) { if (mask == nullptr || len > 16) { @@ -611,11 +617,11 @@ static uint8_t convertNetmaskToBits(const uint8_t* mask, socklen_t len) } #endif /* HAVE_GETIFADDRS */ +#ifdef HAVE_GETIFADDRS std::vector getListOfRangesOfNetworkInterface(const std::string& itf) { std::vector result; -#if HAVE_GETIFADDRS - struct ifaddrs *ifaddr; + struct ifaddrs *ifaddr = nullptr; if (getifaddrs(&ifaddr) == -1) { return result; } @@ -648,6 +654,12 @@ std::vector getListOfRangesOfNetworkInterface(const std::string& itf) } freeifaddrs(ifaddr); -#endif return result; } +#else +std::vector getListOfRangesOfNetworkInterface(const std::string& /* itf */) +{ + std::vector result; + return result; +} +#endif // HAVE_GETIFADDRS -- 2.47.2