summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-04-02 09:46:21 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-04-06 04:14:58 +0000
commit264d814773a15806df497e872e4b19c613c94725 (patch)
tree71d3cbd30599c749a6a28d4482ba005c3ca32986 /src/network
parentb3f474d620f07297c27bf7919a366a5ceb25c20a (diff)
Fix GCC warning about dereferencing type-punned pointers
GCC is wrong. Type-punning is when you read something of a given type as something else. We're not doing that, as it's only read as integer. qnativesocketengine_unix.cpp:1011:79: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] Too bad my plan for a good C++ solution was foiled by glibc developers. Change-Id: I27b55fdf514247549455fffd14b1a27667745e94 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 09c06adb1e..3cf65b3553 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -987,7 +987,8 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
if (cmsgptr->cmsg_len == CMSG_LEN(sizeof(int))
&& ((cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type == IPV6_HOPLIMIT)
|| (cmsgptr->cmsg_level == IPPROTO_IP && cmsgptr->cmsg_type == IP_TTL))) {
- header->hopLimit = *reinterpret_cast<int *>(CMSG_DATA(cmsgptr));
+ Q_STATIC_ASSERT(sizeof(header->hopLimit) == sizeof(int));
+ memcpy(&header->hopLimit, CMSG_DATA(cmsgptr), sizeof(header->hopLimit));
}
#ifndef QT_NO_SCTP