From 8863b8f24fc0751d9b8015b7f1344f76942dbb82 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 24 Apr 2018 10:38:03 -0700 Subject: QSysInfo: Correct the \since for {machine,boot}UniqueId() The code was written before 5.10 was released, but took long to be merged. Change-Id: If90a92b041d3442fa0a4fffd15286fe079b058e1 Reviewed-by: Edward Welbourne --- src/corelib/global/qglobal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index b75b218201..ad015ee048 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2856,7 +2856,7 @@ enum { }; /*! - \since 5.10 + \since 5.11 Returns a unique ID for this machine, if one can be determined. If no unique ID could be determined, this function returns an empty byte array. @@ -2929,7 +2929,7 @@ QByteArray QSysInfo::machineUniqueId() } /*! - \since 5.10 + \since 5.11 Returns a unique ID for this machine's boot, if one can be determined. If no unique ID could be determined, this function returns an empty byte -- cgit v1.2.3 From a2df0ef57add82ccfb3bc3bcfaccc7510d709d98 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 8 May 2018 21:57:07 -0700 Subject: Fix build with GCC 8: memset/memcpy/memmove of non-trivials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qarraydataops.h:73:17: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct TCBPoint’; use assignment or value-initialization instead [-Werror=class-memaccess] Change-Id: I5d0ee9389a794d80983efffd152ce10eb557341f Reviewed-by: Ville Voutilainen --- src/corelib/tools/qarraydataops.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index d0f83d2b6a..7e1b43f9b1 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -65,7 +65,7 @@ struct QPodArrayOps Q_ASSERT(newSize > uint(this->size)); Q_ASSERT(newSize <= this->alloc); - ::memset(this->end(), 0, (newSize - this->size) * sizeof(T)); + ::memset(static_cast(this->end()), 0, (newSize - this->size) * sizeof(T)); this->size = int(newSize); } @@ -121,8 +121,9 @@ struct QPodArrayOps Q_ASSERT(e <= where || b > this->end()); // No overlap Q_ASSERT(size_t(e - b) <= this->alloc - uint(this->size)); - ::memmove(where + (e - b), where, (static_cast(this->end()) - where) * sizeof(T)); - ::memcpy(where, b, (e - b) * sizeof(T)); + ::memmove(static_cast(where + (e - b)), static_cast(where), + (static_cast(this->end()) - where) * sizeof(T)); + ::memcpy(static_cast(where), static_cast(b), (e - b) * sizeof(T)); this->size += (e - b); } @@ -133,7 +134,8 @@ struct QPodArrayOps Q_ASSERT(b >= this->begin() && b < this->end()); Q_ASSERT(e > this->begin() && e < this->end()); - ::memmove(b, e, (static_cast(this->end()) - e) * sizeof(T)); + ::memmove(static_cast(b), static_cast(e), + (static_cast(this->end()) - e) * sizeof(T)); this->size -= (e - b); } }; -- cgit v1.2.3 From 68e6d64fe36511d0d9d8004e7fc1c36bf6c26ed2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 9 May 2018 19:52:26 -0700 Subject: QString: fix off-by-one error The check for having N valid characters is ptr + N <= end, because ptr + N == end indicates that we have exactly N characters in the string. Change-Id: I5d0ee9389a794d80983efffd152d28d5aa485ce4 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/tools/qstring.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index f6360f5504..b2dcb6d8da 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -259,7 +259,7 @@ static bool simdTestMask(const char *&ptr, const char *end, quint32 maskval) # if defined(__AVX2__) // AVX2 implementation: test 32 bytes at a time const __m256i mask256 = _mm256_broadcastd_epi32(_mm_cvtsi32_si128(maskval)); - while (ptr + 32 < end) { + while (ptr + 32 <= end) { __m256i data = _mm256_loadu_si256(reinterpret_cast(ptr)); if (!_mm256_testz_si256(mask256, data)) return false; @@ -271,7 +271,7 @@ static bool simdTestMask(const char *&ptr, const char *end, quint32 maskval) // SSE 4.1 implementation: test 32 bytes at a time (two 16-byte // comparisons, unrolled) const __m128i mask = _mm_set1_epi32(maskval); - while (ptr + 32 < end) { + while (ptr + 32 <= end) { __m128i data1 = _mm_loadu_si128(reinterpret_cast(ptr)); __m128i data2 = _mm_loadu_si128(reinterpret_cast(ptr + 16)); if (!_mm_testz_si128(mask, data1)) @@ -283,7 +283,7 @@ static bool simdTestMask(const char *&ptr, const char *end, quint32 maskval) # endif # if defined(__SSE4_1__) // AVX2 and SSE4.1: final 16-byte comparison - if (ptr + 16 < end) { + if (ptr + 16 <= end) { __m128i data1 = _mm_loadu_si128(reinterpret_cast(ptr)); if (!_mm_testz_si128(mask, data1)) return false; @@ -325,7 +325,7 @@ bool QtPrivate::isAscii(QLatin1String s) Q_DECL_NOTHROW } #endif - while (ptr + 4 < end) { + while (ptr + 4 <= end) { quint32 data = qFromUnaligned(ptr); if (data & 0x80808080U) return false; -- cgit v1.2.3 From 69e0393399e4aba077f29b36611670dbe5813e27 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 May 2018 23:25:43 -0700 Subject: QByteArray::setNum: use the existing latin1 lowercasing table Not sure this makes the code faster, but it removes two functions. Change-Id: I5d0ee9389a794d80983efffd152d830da44b1bfe Reviewed-by: Lars Knoll --- src/corelib/tools/qbytearray.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 83b9f19094..7c601e1336 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -782,19 +782,6 @@ QByteArray qUncompress(const uchar* data, int nbytes) } #endif -static inline bool qIsUpper(char c) -{ - return c >= 'A' && c <= 'Z'; -} - -static inline char qToLower(char c) -{ - if (c >= 'A' && c <= 'Z') - return c - 'A' + 'a'; - else - return c; -} - /*! \class QByteArray \inmodule QtCore @@ -4136,9 +4123,10 @@ QByteArray &QByteArray::setNum(double n, char f, int prec) QLocaleData::DoubleForm form = QLocaleData::DFDecimal; uint flags = QLocaleData::ZeroPadExponent; - if (qIsUpper(f)) + char lower = latin1_lowercased[uchar(f)]; + if (f != lower) flags |= QLocaleData::CapitalEorX; - f = qToLower(f); + f = lower; switch (f) { case 'f': -- cgit v1.2.3