diff options
Diffstat (limited to 'src/network/kernel/qnetworkinterface_linux.cpp')
-rw-r--r-- | src/network/kernel/qnetworkinterface_linux.cpp | 55 |
1 files changed, 11 insertions, 44 deletions
diff --git a/src/network/kernel/qnetworkinterface_linux.cpp b/src/network/kernel/qnetworkinterface_linux.cpp index ce36bf2e11..67ed8006bb 100644 --- a/src/network/kernel/qnetworkinterface_linux.cpp +++ b/src/network/kernel/qnetworkinterface_linux.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Intel Corporation. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qnetworkinterface.h" #include "qnetworkinterface_p.h" @@ -47,7 +11,7 @@ #include <qobjectdefs.h> #include <qvarlengtharray.h> -// accordding to rtnetlink(7) +// according to rtnetlink(7) #include <asm/types.h> #include <linux/if.h> #include <linux/if_arp.h> @@ -147,7 +111,10 @@ struct NetlinkSocket template <typename Lambda> struct ProcessNetlinkRequest { using FunctionTraits = QtPrivate::FunctionPointer<decltype(&Lambda::operator())>; - using FirstArgument = typename FunctionTraits::Arguments::Car; + using FirstArgumentPointer = typename FunctionTraits::Arguments::Car; + using FirstArgument = std::remove_pointer_t<FirstArgumentPointer>; + static_assert(std::is_pointer_v<FirstArgumentPointer>); + static_assert(std::is_aggregate_v<FirstArgument>); static int expectedTypeForRequest(int rtype) { @@ -172,7 +139,7 @@ template <typename Lambda> struct ProcessNetlinkRequest if (!NLMSG_OK(hdr, quint32(len))) return; - auto arg = reinterpret_cast<FirstArgument>(NLMSG_DATA(hdr)); + auto arg = static_cast<FirstArgument *>(NLMSG_DATA(hdr)); size_t payloadLen = NLMSG_PAYLOAD(hdr, 0); // is this a multipart message? @@ -192,7 +159,7 @@ template <typename Lambda> struct ProcessNetlinkRequest // NLMSG_NEXT also updates the len variable hdr = NLMSG_NEXT(hdr, len); - arg = reinterpret_cast<FirstArgument>(NLMSG_DATA(hdr)); + arg = static_cast<FirstArgument *>(NLMSG_DATA(hdr)); payloadLen = NLMSG_PAYLOAD(hdr, 0); } while (NLMSG_OK(hdr, quint32(len))); @@ -222,7 +189,7 @@ void processNetlinkRequest(int sock, struct nlmsghdr *hdr, char *buf, size_t buf uint QNetworkInterfaceManager::interfaceIndexFromName(const QString &name) { uint index = 0; - if (name.length() >= IFNAMSIZ) + if (name.size() >= IFNAMSIZ) return index; int socket = qt_safe_socket(AF_INET, SOCK_DGRAM, 0); @@ -345,7 +312,7 @@ static void getAddresses(int sock, char *buf, QList<QNetworkInterfacePrivate *> // find the interface this is relevant to QNetworkInterfacePrivate *iface = nullptr; - for (auto candidate : qAsConst(result)) { + for (auto candidate : std::as_const(result)) { if (candidate->index != int(ifa->ifa_index)) continue; iface = candidate; |