Fix a few size_t / int conversion warnings

Change the hash function of QTypeRevision and QtFontFallbacksCacheKey
to use size_t and add a few casts.

Change-Id: I89a8fc617abbe8b0c67529ec41795691c99b0574
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Friedemann Kleint 2020-04-10 08:12:55 +02:00
parent 4c4693cf96
commit c0873b7832
5 changed files with 6 additions and 6 deletions

View File

@ -1109,7 +1109,7 @@ int QMetaStringTable::preferredAlignment()
// Returns the size (in bytes) required for serializing this string table.
int QMetaStringTable::blobSize() const
{
int size = m_entries.size() * 2*sizeof(uint);
int size = int(m_entries.size() * 2 * sizeof(uint));
Entries::const_iterator it;
for (it = m_entries.constBegin(); it != m_entries.constEnd(); ++it)
size += it.key().size() + 1;
@ -1139,7 +1139,7 @@ void QMetaStringTable::writeBlob(char *out) const
{
Q_ASSERT(!(reinterpret_cast<quintptr>(out) & (preferredAlignment()-1)));
int offsetOfStringdataMember = m_entries.size() * 2*sizeof(uint);
int offsetOfStringdataMember = int(m_entries.size() * 2 * sizeof(uint));
int stringdataOffset = 0;
// qt_metacast expects the first string in the string table to be the class name.

View File

@ -746,7 +746,7 @@ QDebug operator<<(QDebug debug, const QTypeRevision &revision)
Returns the hash value for the \a key, using \a seed to seed the
calculation.
*/
uint qHash(const QTypeRevision &key, uint seed)
size_t qHash(const QTypeRevision &key, size_t seed)
{
return qHash(key.toEncodedVersion<quint16>(), seed);
}

View File

@ -311,7 +311,7 @@ Q_REQUIRED_RESULT inline bool operator!=(const QVersionNumber &lhs, const QVersi
{ return QVersionNumber::compare(lhs, rhs) != 0; }
class QTypeRevision;
Q_CORE_EXPORT uint qHash(const QTypeRevision &key, uint seed = 0);
Q_CORE_EXPORT size_t qHash(const QTypeRevision &key, size_t seed = 0);
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream& operator<<(QDataStream &out, const QTypeRevision &revision);

View File

@ -545,7 +545,7 @@ bool operator==(const QShader &lhs, const QShader &rhs) Q_DECL_NOTHROW
*/
size_t qHash(const QShader &s, size_t seed) Q_DECL_NOTHROW
{
uint h = s.stage();
size_t h = s.stage();
for (auto it = s.d->shaders.constBegin(), itEnd = s.d->shaders.constEnd(); it != itEnd; ++it)
h += qHash(it.key(), seed) + qHash(it.value().shader(), seed);
return h;

View File

@ -78,7 +78,7 @@ inline bool operator!=(const QtFontFallbacksCacheKey &lhs, const QtFontFallbacks
return !operator==(lhs, rhs);
}
inline uint qHash(const QtFontFallbacksCacheKey &key, uint seed = 0) noexcept
inline size_t qHash(const QtFontFallbacksCacheKey &key, size_t seed = 0) noexcept
{
QtPrivate::QHashCombine hash;
seed = hash(seed, key.family);