From 9d4579c1cd0aae5f75c8702826b5d874a6aae83e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 1 Aug 2023 12:21:02 -0700 Subject: [PATCH] CMake: modernize ipv6ifname and getifaddrs config checks with QT_CONFIG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I've left the QT_NO_ macros because they were public. No one should be using them (and they are now 1 on Linux, so you had better not be using them), but just in case. Change-Id: Ifbf974a4d10745b099b1fffd177758a7a26e4244 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Timur Pocheptsov Reviewed-by: Alexandru Croitor --- src/network/kernel/qnetworkinterface_unix.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp index 082d83e9dc..fc508e7095 100644 --- a/src/network/kernel/qnetworkinterface_unix.cpp +++ b/src/network/kernel/qnetworkinterface_unix.cpp @@ -17,11 +17,7 @@ # include "qdatetime.h" #endif -#if defined(QT_LINUXBASE) -# define QT_NO_GETIFADDRS -#endif - -#ifndef QT_NO_GETIFADDRS +#if QT_CONFIG(getifaddrs) # include #endif @@ -61,7 +57,7 @@ static QHostAddress addressFromSockaddr(sockaddr *sa, int ifindex = 0, const QSt uint QNetworkInterfaceManager::interfaceIndexFromName(const QString &name) { -#ifndef QT_NO_IPV6IFNAME +#if QT_CONFIG(ipv6ifname) return ::if_nametoindex(name.toLatin1()); #elif defined(SIOCGIFINDEX) struct ifreq req; @@ -90,7 +86,7 @@ uint QNetworkInterfaceManager::interfaceIndexFromName(const QString &name) QString QNetworkInterfaceManager::interfaceNameFromIndex(uint index) { -#ifndef QT_NO_IPV6IFNAME +#if QT_CONFIG(ipv6ifname) char buf[IF_NAMESIZE]; if (::if_indextoname(index, buf)) return QString::fromLatin1(buf); @@ -124,13 +120,13 @@ static int getMtu(int socket, struct ifreq *req) return 0; } -#ifdef QT_NO_GETIFADDRS +#if !QT_CONFIG(getifaddrs) // getifaddrs not available static QSet interfaceNames(int socket) { QSet result; -#ifdef QT_NO_IPV6IFNAME +#if !QT_CONFIG(ipv6ifname) QByteArray storageBuffer; struct ifconf interfaceList; static const int STORAGEBUFFER_GROWTH = 256; @@ -185,7 +181,7 @@ static QNetworkInterfacePrivate *findInterface(int socket, QList= 0)