aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2020-02-07 00:04:36 -0500
committerAndres Salomon <dilinger@queued.net>2020-02-07 00:04:36 -0500
commit1af2dffb70862a59801a73dacedc695bb062977a (patch)
treeec2e7a51a87ca1be32ea0d4479d82af4f4d21ad1
parente3a5b3a5e5253fc5ce67574b01e8d25ec14e4d25 (diff)
downloadlibquotient-1af2dffb70862a59801a73dacedc695bb062977a.tar.gz
libquotient-1af2dffb70862a59801a73dacedc695bb062977a.zip
Fix build on big-endian systems
On little-endian systems, this call to qToLittleEndian(hash) disappears completely. On big-endian systems, it turns into qbswap(hash), and causes a build error. qbswap() isn't defined for QByteArrays, because QByteArray isn't an array containing multi-byte elements. Since each element is a single byte, machine endianness isn't a factor. (If we really wanted to swap the bytes, we'd need to reverse every 4 bytes of the array.) This just drops the call to QToLittleEndian completely. The lines after it converts part of the hash to a QDataStream, which DOES have to worry about endianness, but that code is also specifically calling QDataStream::setByteOrder to specify little-endian.
-rw-r--r--lib/util.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/util.cpp b/lib/util.cpp
index 9f4ac85f..4cbebfe2 100644
--- a/lib/util.cpp
+++ b/lib/util.cpp
@@ -104,7 +104,7 @@ qreal Quotient::stringToHueF(const QString& s)
Q_ASSERT(!s.isEmpty());
QByteArray hash = QCryptographicHash::hash(s.toUtf8(),
QCryptographicHash::Sha1);
- QDataStream dataStream(qToLittleEndian(hash).left(2));
+ QDataStream dataStream(hash.left(2));
dataStream.setByteOrder(QDataStream::LittleEndian);
quint16 hashValue;
dataStream >> hashValue;