summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qnetworkinterface_unix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/kernel/qnetworkinterface_unix.cpp')
-rw-r--r--src/network/kernel/qnetworkinterface_unix.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp
index d04ea085c2..da53ccfe70 100644
--- a/src/network/kernel/qnetworkinterface_unix.cpp
+++ b/src/network/kernel/qnetworkinterface_unix.cpp
@@ -320,29 +320,29 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
}
#endif
- // Get the interface broadcast address
- QNetworkAddressEntry entry;
- if (iface->flags & QNetworkInterface::CanBroadcast) {
- if (qt_safe_ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) {
- sockaddr *sa = &req.ifr_addr;
- if (sa->sa_family == AF_INET)
- entry.setBroadcast(addressFromSockaddr(sa));
- }
- }
-
// Get the address of the interface
+ QNetworkAddressEntry entry;
if (qt_safe_ioctl(socket, SIOCGIFADDR, &req) >= 0) {
sockaddr *sa = &req.ifr_addr;
entry.setIp(addressFromSockaddr(sa));
- }
- // Get the interface netmask
- if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) {
- sockaddr *sa = &req.ifr_addr;
- entry.setNetmask(addressFromSockaddr(sa));
- }
+ // Get the interface broadcast address
+ if (iface->flags & QNetworkInterface::CanBroadcast) {
+ if (qt_safe_ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) {
+ sockaddr *sa = &req.ifr_addr;
+ if (sa->sa_family == AF_INET)
+ entry.setBroadcast(addressFromSockaddr(sa));
+ }
+ }
- iface->addressEntries << entry;
+ // Get the interface netmask
+ if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) {
+ sockaddr *sa = &req.ifr_addr;
+ entry.setNetmask(addressFromSockaddr(sa));
+ }
+
+ iface->addressEntries << entry;
+ }
}
::close(socket);
@@ -395,7 +395,7 @@ static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList)
// - virtual interfaces with no HW address have no AF_PACKET
// - interface labels have no AF_PACKET, but shouldn't be shown as a new interface
for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) {
- if (ptr->ifa_addr && ptr->ifa_addr->sa_family != AF_PACKET) {
+ if (!ptr->ifa_addr || ptr->ifa_addr->sa_family != AF_PACKET) {
QString name = QString::fromLatin1(ptr->ifa_name);
if (seenInterfaces.contains(name))
continue;