From ff776a3059b25f8dd3c3abbd6aa8ffa95ec9cf7a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 20 Oct 2020 11:42:50 +0200 Subject: Whitespace cleanup in corelib/global Change-Id: I087d7d949cfd43e48e8a008621a4eeaa9d104ceb Reviewed-by: Thiago Macieira --- src/corelib/global/qcontainerinfo.h | 3 +-- src/corelib/global/qendian.cpp | 13 ++++++---- src/corelib/global/qendian_p.h | 49 ++++++++++++++++--------------------- src/corelib/global/qflags.h | 4 +-- src/corelib/global/qglobal.cpp | 22 ++++++++--------- src/corelib/global/qglobal.h | 4 +-- src/corelib/global/qglobalstatic.h | 24 +++++++++++++----- src/corelib/global/qlibraryinfo.h | 5 ++-- src/corelib/global/qlogging.cpp | 42 +++++++++++++++++++------------ src/corelib/global/qlogging.h | 9 ++++++- src/corelib/global/qmalloc.cpp | 5 ++-- src/corelib/global/qnumeric_p.h | 9 ++++--- src/corelib/global/qrandom.cpp | 6 +++-- src/corelib/global/qrandom_p.h | 5 ++-- src/corelib/global/qsimd.cpp | 45 +++++++++++++++++++++------------- src/corelib/global/qsysinfo.h | 3 ++- 16 files changed, 142 insertions(+), 106 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcontainerinfo.h b/src/corelib/global/qcontainerinfo.h index 99a674fc71..76059131e0 100644 --- a/src/corelib/global/qcontainerinfo.h +++ b/src/corelib/global/qcontainerinfo.h @@ -45,8 +45,7 @@ QT_BEGIN_NAMESPACE -namespace QContainerTraits -{ +namespace QContainerTraits { template using value_type = typename C::value_type; diff --git a/src/corelib/global/qendian.cpp b/src/corelib/global/qendian.cpp index c69572cccf..cc9158e34d 100644 --- a/src/corelib/global/qendian.cpp +++ b/src/corelib/global/qendian.cpp @@ -815,7 +815,7 @@ size_t simdSwapLoop(const uchar *src, size_t bytes, uchar *dst) noexcept size_t i = sseSwapLoop(src, bytes, dst, shuffleMaskPtr); // epilogue - for (size_t _i = 0 ; i < bytes && _i < sizeof(__m128i); i += sizeof(T), _i += sizeof(T)) + for (size_t _i = 0; i < bytes && _i < sizeof(__m128i); i += sizeof(T), _i += sizeof(T)) qbswap(qFromUnaligned(src + i), dst + i); // return the total, so the bswapLoop below does nothing @@ -886,12 +886,13 @@ void *bswapLoop(const uchar *src, size_t n, uchar *dst) noexcept size_t i = simdSwapLoop(src, n, dst); - for ( ; i < n; i += sizeof(T)) + for (; i < n; i += sizeof(T)) qbswap(qFromUnaligned(src + i), dst + i); return dst + i; } -template <> void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcept +template<> +void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcept { const uchar *src = reinterpret_cast(source); uchar *dst = reinterpret_cast(dest); @@ -899,7 +900,8 @@ template <> void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcep return bswapLoop(src, n << 1, dst); } -template <> void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcept +template<> +void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcept { const uchar *src = reinterpret_cast(source); uchar *dst = reinterpret_cast(dest); @@ -907,7 +909,8 @@ template <> void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcep return bswapLoop(src, n << 2, dst); } -template <> void *qbswap<8>(const void *source, qsizetype n, void *dest) noexcept +template<> +void *qbswap<8>(const void *source, qsizetype n, void *dest) noexcept { const uchar *src = reinterpret_cast(source); uchar *dst = reinterpret_cast(dest); diff --git a/src/corelib/global/qendian_p.h b/src/corelib/global/qendian_p.h index d0d79d4ce4..bc6194fb06 100644 --- a/src/corelib/global/qendian_p.h +++ b/src/corelib/global/qendian_p.h @@ -73,12 +73,12 @@ public: // FIXME: val is public until qtdeclarative is fixed to not access it directly. UT val; - QSpecialIntegerBitfield &operator =(T t) + QSpecialIntegerBitfield &operator=(T t) { UT i = S::fromSpecial(val); i &= ~mask(); i |= (UT(t) << pos) & mask(); - val = S::toSpecial(i); + val = S::toSpecial(i); return *this; } operator T() const @@ -93,32 +93,26 @@ public: return (S::fromSpecial(val) & mask()) >> pos; } - bool operator !() const { return !(val & S::toSpecial(mask())); } - bool operator ==(QSpecialIntegerBitfield i) const - { return ((val ^ i.val) & S::toSpecial(mask())) == 0; } - bool operator !=(QSpecialIntegerBitfield i) const - { return ((val ^ i.val) & S::toSpecial(mask())) != 0; } + bool operator!() const { return !(val & S::toSpecial(mask())); } + bool operator==(QSpecialIntegerBitfield i) const + { + return ((val ^ i.val) & S::toSpecial(mask())) == 0; + } + bool operator!=(QSpecialIntegerBitfield i) const + { + return ((val ^ i.val) & S::toSpecial(mask())) != 0; + } - QSpecialIntegerBitfield &operator +=(T i) - { return (*this = (T(*this) + i)); } - QSpecialIntegerBitfield &operator -=(T i) - { return (*this = (T(*this) - i)); } - QSpecialIntegerBitfield &operator *=(T i) - { return (*this = (T(*this) * i)); } - QSpecialIntegerBitfield &operator /=(T i) - { return (*this = (T(*this) / i)); } - QSpecialIntegerBitfield &operator %=(T i) - { return (*this = (T(*this) % i)); } - QSpecialIntegerBitfield &operator |=(T i) - { return (*this = (T(*this) | i)); } - QSpecialIntegerBitfield &operator &=(T i) - { return (*this = (T(*this) & i)); } - QSpecialIntegerBitfield &operator ^=(T i) - { return (*this = (T(*this) ^ i)); } - QSpecialIntegerBitfield &operator >>=(T i) - { return (*this = (T(*this) >> i)); } - QSpecialIntegerBitfield &operator <<=(T i) - { return (*this = (T(*this) << i)); } + QSpecialIntegerBitfield &operator+=(T i) { return (*this = (T(*this) + i)); } + QSpecialIntegerBitfield &operator-=(T i) { return (*this = (T(*this) - i)); } + QSpecialIntegerBitfield &operator*=(T i) { return (*this = (T(*this) * i)); } + QSpecialIntegerBitfield &operator/=(T i) { return (*this = (T(*this) / i)); } + QSpecialIntegerBitfield &operator%=(T i) { return (*this = (T(*this) % i)); } + QSpecialIntegerBitfield &operator|=(T i) { return (*this = (T(*this) | i)); } + QSpecialIntegerBitfield &operator&=(T i) { return (*this = (T(*this) & i)); } + QSpecialIntegerBitfield &operator^=(T i) { return (*this = (T(*this) ^ i)); } + QSpecialIntegerBitfield &operator>>=(T i) { return (*this = (T(*this) >> i)); } + QSpecialIntegerBitfield &operator<<=(T i) { return (*this = (T(*this) << i)); } }; template @@ -136,7 +130,6 @@ using qint32_be_bitfield = QBEIntegerBitfield; template using quint32_be_bitfield = QBEIntegerBitfield; - QT_END_NAMESPACE #endif // QENDIAN_P_H diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index ded933880e..94d9e45acb 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -89,8 +89,8 @@ template class QFlags { static_assert((sizeof(Enum) <= sizeof(int)), - "QFlags uses an int as storage, so an enum with underlying " - "long long will overflow."); + "QFlags uses an int as storage, so an enum with underlying " + "long long will overflow."); static_assert((std::is_enum::value), "QFlags is only usable on enumeration types."); public: diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 4c7a5e0f78..749da79a1f 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1963,7 +1963,7 @@ QWindowsSockInit::QWindowsSockInit() WSAData wsadata; // IPv6 requires Winsock v2.0 or better. - if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) { + if (WSAStartup(MAKEWORD(2, 0), &wsadata) != 0) { qWarning("QTcpSocketAPI: WinSock v2.0 initialization failed."); } else { version = 0x20; @@ -2095,7 +2095,7 @@ static bool readEtcFile(QUnixOSVersion &v, const char *filename, const char *end = buffer.constEnd(); const char *eol; QByteArray line; - for ( ; ptr != end; ptr = eol + 1) { + for (; ptr != end; ptr = eol + 1) { // find the end of the line after ptr eol = static_cast(memchr(ptr, '\n', end - ptr)); if (!eol) @@ -3135,17 +3135,17 @@ void qt_assert_x(const char *where, const char *what, const char *file, int line Q_CORE_EXPORT Q_DECL_CONST_FUNCTION unsigned int qt_int_sqrt(unsigned int n) { // n must be in the range 0...UINT_MAX/2-1 - if (n >= (UINT_MAX>>2)) { + if (n >= (UINT_MAX >> 2)) { unsigned int r = 2 * qt_int_sqrt(n / 4); unsigned int r2 = r + 1; return (n >= r2 * r2) ? r2 : r; } - uint h, p= 0, q= 1, r= n; + uint h, p = 0, q = 1, r = n; while (q <= n) q <<= 2; while (q != 1) { q >>= 2; - h= p + q; + h = p + q; p >>= 1; if (r >= h) { p += q; @@ -3229,7 +3229,6 @@ QByteArray qgetenv(const char *varName) #endif } - /*! \fn QString qEnvironmentVariable(const char *varName, const QString &defaultValue) \fn QString qEnvironmentVariable(const char *varName) @@ -3459,7 +3458,7 @@ bool qEnvironmentVariableIsSet(const char *varName) noexcept \sa qgetenv(), qEnvironmentVariable() */ -bool qputenv(const char *varName, const QByteArray& value) +bool qputenv(const char *varName, const QByteArray &value) { const auto locker = qt_scoped_lock(environmentMutex); #if defined(Q_CC_MSVC) @@ -3471,7 +3470,7 @@ bool qputenv(const char *varName, const QByteArray& value) QByteArray buffer(varName); buffer += '='; buffer += value; - char* envVar = qstrdup(buffer.constData()); + char *envVar = qstrdup(buffer.constData()); int result = putenv(envVar); if (result != 0) // error. we have to delete the string. delete[] envVar; @@ -4024,7 +4023,8 @@ bool qunsetenv(const char *varName) with meaningful parameter names in their signatures. */ -struct QInternal_CallBackTable { +struct QInternal_CallBackTable +{ QList> callbacks; }; @@ -4046,7 +4046,7 @@ bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback) if (unsigned(cb) < unsigned(QInternal::LastCallback)) { if (global_callback_table.exists()) { QInternal_CallBackTable *cbt = global_callback_table(); - return (bool) cbt->callbacks[cb].removeAll(callback); + return cbt->callbacks[cb].removeAll(callback) > 0; } } return false; @@ -4063,7 +4063,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) if (cbt && cb < cbt->callbacks.size()) { QList callbacks = cbt->callbacks[cb]; bool ret = false; - for (int i=0; i struct QIntegerForSize<16> { __extension__ typedef unsigned __int template struct QIntegerForSizeof: QIntegerForSize { }; typedef QIntegerForSize::Signed qregisterint; typedef QIntegerForSize::Unsigned qregisteruint; -typedef QIntegerForSizeof::Unsigned quintptr; -typedef QIntegerForSizeof::Signed qptrdiff; +typedef QIntegerForSizeof::Unsigned quintptr; +typedef QIntegerForSizeof::Signed qptrdiff; typedef qptrdiff qintptr; using qsizetype = QIntegerForSizeof::Signed; diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index e56fe1dbcb..a0dfd462fd 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -132,17 +132,29 @@ struct QGlobalStatic bool isDestroyed() const { return guard.loadRelaxed() <= QtGlobalStatic::Destroyed; } bool exists() const { return guard.loadRelaxed() == QtGlobalStatic::Initialized; } - operator Type *() { if (isDestroyed()) return nullptr; return innerFunction(); } - Type *operator()() { if (isDestroyed()) return nullptr; return innerFunction(); } + operator Type *() + { + if (isDestroyed()) + return nullptr; + return innerFunction(); + } + Type *operator()() + { + if (isDestroyed()) + return nullptr; + return innerFunction(); + } Type *operator->() { - Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed"); - return innerFunction(); + Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", + "The global static was used after being destroyed"); + return innerFunction(); } Type &operator*() { - Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed"); - return *innerFunction(); + Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", + "The global static was used after being destroyed"); + return *innerFunction(); } }; diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index bb5c9a8e08..04956052b3 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QLibraryInfo { public: - static const char * build() noexcept; + static const char *build() noexcept; static bool isDebugBuild(); @@ -57,8 +57,7 @@ public: static QVersionNumber version() noexcept Q_DECL_CONST_FUNCTION; #endif - enum LibraryPath - { + enum LibraryPath { PrefixPath = 0, DocumentationPath, HeadersPath, diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 0e9dd3b5ee..52a565aa45 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1069,8 +1069,8 @@ static const char emptyTokenC[] = ""; static const char defaultPattern[] = "%{if-category}%{category}: %{endif}%{message}"; - -struct QMessagePattern { +struct QMessagePattern +{ QMessagePattern(); ~QMessagePattern(); @@ -1078,13 +1078,14 @@ struct QMessagePattern { // 0 terminated arrays of literal tokens / literal or placeholder tokens std::unique_ptr[]> literals; - std::unique_ptr tokens; - QList timeArgs; // timeFormats in sequence of %{time + std::unique_ptr tokens; + QList timeArgs; // timeFormats in sequence of %{time #ifndef QT_BOOTSTRAPPED QElapsedTimer timer; #endif #ifdef QLOGGING_HAVE_BACKTRACE - struct BacktraceParams { + struct BacktraceParams + { QString backtraceSeparator; int backtraceDepth; }; @@ -1115,8 +1116,7 @@ QMessagePattern::QMessagePattern() } } -QMessagePattern::~QMessagePattern() - = default; +QMessagePattern::~QMessagePattern() = default; void QMessagePattern::setPattern(const QString &pattern) { @@ -1158,7 +1158,7 @@ void QMessagePattern::setPattern(const QString &pattern) // tokenizer std::vector> literalsVar; - tokens.reset(new const char*[lexemes.size() + 1]); + tokens.reset(new const char *[lexemes.size() + 1]); tokens[lexemes.size()] = nullptr; bool nestedIfError = false; @@ -1290,7 +1290,7 @@ static QStringList backtraceFramesForLogMessage(int frameCount) // This code is protected by QMessagePattern::mutex so it is thread safe on all compilers static const QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$")); - QVarLengthArray buffer(8 + frameCount); + QVarLengthArray buffer(8 + frameCount); int n = backtrace(buffer.data(), buffer.size()); if (n > 0) { int numberPrinted = 0; @@ -1642,11 +1642,21 @@ static bool android_default_message_handler(QtMsgType type, android_LogPriority priority = ANDROID_LOG_DEBUG; switch (type) { - case QtDebugMsg: priority = ANDROID_LOG_DEBUG; break; - case QtInfoMsg: priority = ANDROID_LOG_INFO; break; - case QtWarningMsg: priority = ANDROID_LOG_WARN; break; - case QtCriticalMsg: priority = ANDROID_LOG_ERROR; break; - case QtFatalMsg: priority = ANDROID_LOG_FATAL; break; + case QtDebugMsg: + priority = ANDROID_LOG_DEBUG; + break; + case QtInfoMsg: + priority = ANDROID_LOG_INFO; + break; + case QtWarningMsg: + priority = ANDROID_LOG_WARN; + break; + case QtCriticalMsg: + priority = ANDROID_LOG_ERROR; + break; + case QtFatalMsg: + priority = ANDROID_LOG_FATAL; + break; }; __android_log_print(priority, qPrintable(QCoreApplication::applicationName()), "%s\n", qPrintable(formattedMessage)); @@ -1666,8 +1676,8 @@ static void win_outputDebugString_helper(QStringView message) OutputDebugString(reinterpret_cast(message.utf16())); } else { wchar_t *messagePart = new wchar_t[maxOutputStringLength + 1]; - for (int i = 0; i < message.length(); i += maxOutputStringLength ) { - const int length = std::min(message.length() - i, maxOutputStringLength ); + for (int i = 0; i < message.length(); i += maxOutputStringLength) { + const int length = std::min(message.length() - i, maxOutputStringLength); const int len = message.mid(i, length).toWCharArray(messagePart); Q_ASSERT(len == length); messagePart[len] = 0; diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index e905929c78..ecf60f747c 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -57,7 +57,14 @@ QT_BEGIN_NAMESPACE class QDebug; class QNoDebug; -enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtInfoMsg, QtSystemMsg = QtCriticalMsg }; +enum QtMsgType { + QtDebugMsg, + QtWarningMsg, + QtCriticalMsg, + QtFatalMsg, + QtInfoMsg, + QtSystemMsg = QtCriticalMsg +}; class QMessageLogContext { diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index fbea0e5689..aeba9ed19b 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -58,9 +58,9 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align { // fake an aligned allocation void *actualptr = oldptr ? static_cast(oldptr)[-1] : nullptr; - if (alignment <= sizeof(void*)) { + if (alignment <= sizeof(void *)) { // special, fast case - void **newptr = static_cast(realloc(actualptr, newsize + sizeof(void*))); + void **newptr = static_cast(realloc(actualptr, newsize + sizeof(void *))); if (!newptr) return nullptr; if (newptr == actualptr) { @@ -112,4 +112,3 @@ void qFreeAligned(void *ptr) } QT_END_NAMESPACE - diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index c7d44591cc..a11057dfff 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -130,7 +130,7 @@ Q_DECL_CONST_FUNCTION static inline int fpclassify(float f) { return std::fpclas constexpr Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept { static_assert(std::numeric_limits::has_infinity, - "platform has no definition for infinity for type double"); + "platform has no definition for infinity for type double"); return std::numeric_limits::infinity(); } @@ -138,7 +138,7 @@ constexpr Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept constexpr Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept { static_assert(std::numeric_limits::has_signaling_NaN, - "platform has no definition for signaling NaN for type double"); + "platform has no definition for signaling NaN for type double"); return std::numeric_limits::signaling_NaN(); } #endif @@ -147,7 +147,7 @@ constexpr Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept constexpr Q_DECL_CONST_FUNCTION static inline double qt_qnan() noexcept { static_assert(std::numeric_limits::has_quiet_NaN, - "platform has no definition for quiet NaN for type double"); + "platform has no definition for quiet NaN for type double"); return std::numeric_limits::quiet_NaN(); } @@ -203,7 +203,8 @@ namespace { This function works for v containing infinities, but not NaN. It's the caller's responsibility to exclude that possibility before calling it. */ -template static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgrade = true) +template +static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgrade = true) { static_assert(std::numeric_limits::is_integer); diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index d12d8cd287..34cc591724 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -181,7 +181,8 @@ struct QRandomGenerator::SystemGenerator // For std::mersenne_twister_engine implementations that use something // other than quint32 (unsigned int) to fill their buffers. - template void generate(T *begin, T *end) + template + void generate(T *begin, T *end) { static_assert(sizeof(T) >= sizeof(quint32)); if (sizeof(T) == sizeof(quint32)) { @@ -414,7 +415,8 @@ struct QRandomGenerator::SystemAndGlobalGenerators new (&rng->storage.engine()) RandomEngine(self()->sys); } - struct PRNGLocker { + struct PRNGLocker + { const bool locked; PRNGLocker(const QRandomGenerator *that) : locked(that == globalNoInit()) diff --git a/src/corelib/global/qrandom_p.h b/src/corelib/global/qrandom_p.h index 934a9282b8..052aef262e 100644 --- a/src/corelib/global/qrandom_p.h +++ b/src/corelib/global/qrandom_p.h @@ -76,13 +76,12 @@ Q_CORE_EXPORT QBasicAtomicInteger qt_randomdevice_control = Q_BASIC_ATOMIC #elif defined(QT_BUILD_INTERNAL) extern Q_CORE_EXPORT QBasicAtomicInteger qt_randomdevice_control; #else -static const struct { +static const struct +{ uint loadAcquire() const { return 0; } } qt_randomdevice_control; #endif - - QT_END_NAMESPACE #endif // QRANDOM_P_H diff --git a/src/corelib/global/qsimd.cpp b/src/corelib/global/qsimd.cpp index d91c1542c2..c2db117853 100644 --- a/src/corelib/global/qsimd.cpp +++ b/src/corelib/global/qsimd.cpp @@ -428,38 +428,46 @@ static quint64 detectProcessorFeatures() // QSimpleBuffer, which has the bare minimum needed to use memory // dynamically and read lines from /proc/cpuinfo of arbitrary sizes. // -struct QSimpleBuffer { +struct QSimpleBuffer +{ static const int chunk_size = 256; char *data; unsigned alloc; unsigned size; - QSimpleBuffer(): data(0), alloc(0), size(0) {} + QSimpleBuffer() : data(nullptr), alloc(0), size(0) { } ~QSimpleBuffer() { ::free(data); } - void resize(unsigned newsize) { + void resize(unsigned newsize) + { if (newsize > alloc) { unsigned newalloc = chunk_size * ((newsize / chunk_size) + 1); - if (newalloc < newsize) newalloc = newsize; + if (newalloc < newsize) + newalloc = newsize; if (newalloc != alloc) { - data = static_cast(::realloc(data, newalloc)); + data = static_cast(::realloc(data, newalloc)); alloc = newalloc; } } size = newsize; } - void append(const QSimpleBuffer &other, unsigned appendsize) { + void append(const QSimpleBuffer &other, unsigned appendsize) + { unsigned oldsize = size; resize(oldsize + appendsize); ::memcpy(data + oldsize, other.data, appendsize); } - void popleft(unsigned amount) { - if (amount >= size) return resize(0); + void popleft(unsigned amount) + { + if (amount >= size) + return resize(0); size -= amount; ::memmove(data, data + amount, size); } - char* cString() { - if (!alloc) resize(1); + char *cString() + { + if (!alloc) + resize(1); return (data[size] = '\0', data); } }; @@ -473,7 +481,7 @@ struct QSimpleBuffer { static void bufReadLine(int fd, QSimpleBuffer &line, QSimpleBuffer &buffer) { for (;;) { - char *newline = static_cast(::memchr(buffer.data, '\n', buffer.size)); + char *newline = static_cast(::memchr(buffer.data, '\n', buffer.size)); if (newline) { unsigned piece_size = newline - buffer.data + 1; line.append(buffer, piece_size); @@ -486,9 +494,12 @@ static void bufReadLine(int fd, QSimpleBuffer &line, QSimpleBuffer &buffer) buffer.resize(buffer.size + QSimpleBuffer::chunk_size); buffer.size = oldsize; } - ssize_t read_bytes = ::qt_safe_read(fd, buffer.data + buffer.size, QSimpleBuffer::chunk_size); - if (read_bytes > 0) buffer.size += read_bytes; - else return; + ssize_t read_bytes = + ::qt_safe_read(fd, buffer.data + buffer.size, QSimpleBuffer::chunk_size); + if (read_bytes > 0) + buffer.size += read_bytes; + else + return; } } @@ -509,7 +520,7 @@ static bool procCpuinfoContains(const char *prefix, const char *string) do { line.resize(0); bufReadLine(cpuinfo_fd, line, buffer); - char *colon = static_cast(::memchr(line.data, ':', line.size)); + char *colon = static_cast(::memchr(line.data, ':', line.size)); if (colon && line.size > prefix_len + string_len) { if (!::strncmp(prefix, line.data, prefix_len)) { // prefix matches, next character must be ':' or space @@ -657,10 +668,10 @@ static QT_FUNCTION_TARGET(RDSEED) unsigned *qt_random_rdseed(unsigned *ptr, unsi // If the independent bit generator used by RDSEED is out of entropy, it // may take time to replenish. // https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide - while (ptr + sizeof(randuint)/sizeof(*ptr) <= end) { + while (ptr + sizeof(randuint) / sizeof(*ptr) <= end) { if (_rdseedXX_step(reinterpret_cast(ptr)) == 0) goto out; - ptr += sizeof(randuint)/sizeof(*ptr); + ptr += sizeof(randuint) / sizeof(*ptr); } if (sizeof(*ptr) != sizeof(randuint) && ptr != end) { diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h index a6d9104d2d..89e761c662 100644 --- a/src/corelib/global/qsysinfo.h +++ b/src/corelib/global/qsysinfo.h @@ -50,7 +50,8 @@ QT_BEGIN_NAMESPACE */ class QString; -class Q_CORE_EXPORT QSysInfo { +class Q_CORE_EXPORT QSysInfo +{ public: enum Sizes { WordSize = (sizeof(void *)<<3) -- cgit v1.2.3