diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-01-21 13:03:09 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-01-21 13:03:09 +0100 |
commit | f94ca82e0ff6345648b499911411f2dcc1849267 (patch) | |
tree | bc5acac8bfecaf5bccc612f5b009bf249bc69ef1 /src/corelib/global | |
parent | fe29a6a6ebbf28505df7cdf1de24fa540fd3745e (diff) | |
parent | b1092a7d4240d419cc2b5f3f5c326a1cb680bbdd (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
.qmake.conf
Change-Id: Ibfcb30053f3aacb8ec2ec480e146538c9bf440ea
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 12 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 14 |
2 files changed, 16 insertions, 10 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index c0d46b73d9..055455c431 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2933,18 +2933,18 @@ enum { QByteArray QSysInfo::machineUniqueId() { #ifdef Q_OS_BSD4 - char uuid[UuidStringLen]; + char uuid[UuidStringLen + 1]; size_t uuidlen = sizeof(uuid); # ifdef KERN_HOSTUUID int name[] = { CTL_KERN, KERN_HOSTUUID }; if (sysctl(name, sizeof name / sizeof name[0], &uuid, &uuidlen, nullptr, 0) == 0 && uuidlen == sizeof(uuid)) - return QByteArray(uuid, uuidlen); + return QByteArray(uuid, uuidlen - 1); # else // Darwin: no fixed value, we need to search by name if (sysctlbyname("kern.uuid", uuid, &uuidlen, nullptr, 0) == 0 && uuidlen == sizeof(uuid)) - return QByteArray(uuid, uuidlen); + return QByteArray(uuid, uuidlen - 1); # endif #elif defined(Q_OS_UNIX) // The modern name on Linux is /etc/machine-id, but that path is @@ -2967,7 +2967,7 @@ QByteArray QSysInfo::machineUniqueId() #elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT) // Let's poke at the registry HKEY key = NULL; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ, &key) + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ | KEY_WOW64_64KEY, &key) == ERROR_SUCCESS) { wchar_t buffer[UuidStringLen + 1]; DWORD size = sizeof(buffer); @@ -3008,11 +3008,11 @@ QByteArray QSysInfo::bootUniqueId() } #elif defined(Q_OS_DARWIN) // "kern.bootsessionuuid" is only available by name - char uuid[UuidStringLen]; + char uuid[UuidStringLen + 1]; size_t uuidlen = sizeof(uuid); if (sysctlbyname("kern.bootsessionuuid", uuid, &uuidlen, nullptr, 0) == 0 && uuidlen == sizeof(uuid)) - return QByteArray(uuid, uuidlen); + return QByteArray(uuid, uuidlen - 1); #endif return QByteArray(); }; diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e3073d80ec..1e4ccae65b 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1054,14 +1054,20 @@ for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \ template <typename T> inline T *qGetPtrHelper(T *ptr) { return ptr; } template <typename Ptr> inline auto qGetPtrHelper(const Ptr &ptr) -> decltype(ptr.operator->()) { return ptr.operator->(); } +// The body must be a statement: +#define Q_CAST_IGNORE_ALIGN(body) QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wcast-align") body QT_WARNING_POP #define Q_DECLARE_PRIVATE(Class) \ - inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); } \ - inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); } \ + inline Class##Private* d_func() \ + { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr));) } \ + inline const Class##Private* d_func() const \ + { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr));) } \ friend class Class##Private; #define Q_DECLARE_PRIVATE_D(Dptr, Class) \ - inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(Dptr)); } \ - inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(Dptr)); } \ + inline Class##Private* d_func() \ + { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<Class##Private *>(qGetPtrHelper(Dptr));) } \ + inline const Class##Private* d_func() const \ + { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<const Class##Private *>(qGetPtrHelper(Dptr));) } \ friend class Class##Private; #define Q_DECLARE_PUBLIC(Class) \ |