QNetworkInterface/Unix: replace one Q_ASSERT with static_asserts

This requires compilers with constexpr offsetof(), which Clang seems to
be since at least 3.0 and GCC since 4.7, both of which are way older
than anything we need to support.

Pick-to: 6.5
Change-Id: I7f354474adce419ca6c2fffd1748b3dcfc616f4a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
bb10
Thiago Macieira 2023-03-02 12:23:42 -08:00
parent e2446afaa1
commit 2a19c7ed13
1 changed files with 2 additions and 1 deletions

View File

@ -459,7 +459,8 @@ static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList)
// ensure both structs start with the name field, of size IFNAMESIZ
static_assert(sizeof(mediareq.ifm_name) == sizeof(req.ifr_name));
Q_ASSERT(&mediareq.ifm_name == &req.ifr_name);
static_assert(offsetof(struct ifmediareq, ifm_name) == 0);
static_assert(offsetof(struct ifreq, ifr_name) == 0);
// on NetBSD we use AF_LINK and sockaddr_dl
// scan the list for that family