From: Fred Morcos Date: Wed, 16 Aug 2023 12:14:21 +0000 (+0200) Subject: Consistency: Use #ifdef instead of #if in iputils.cc X-Git-Tag: rec-5.0.0-alpha1~49^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F13144%2Fhead;p=thirdparty%2Fpdns.git Consistency: Use #ifdef instead of #if in iputils.cc --- 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