From 214df31916c53e46348173fc02fe53f2b9db729a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 12 Jan 2022 09:58:00 -0800 Subject: [PATCH] Add a few explicit conversions back from int MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suppresses GCC's -Wconversion, which is not enabled by default. error: conversion from ‘int’ to ‘quint8’ {aka ‘unsigned char’} may change value [-Werror=conversion] Change-Id: I0e5f6bec596a4a78bd3bfffd16c998102bd51f7c Reviewed-by: Edward Welbourne Reviewed-by: Marc Mutz --- src/corelib/kernel/qmetatype.h | 2 +- src/corelib/tools/qalgorithms.h | 4 ++-- src/corelib/tools/qtaggedpointer.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 2208460a206..dd37ab2fa1b 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -417,7 +417,7 @@ public: { return QMetaType(type).name(); } QT_DEPRECATED_VERSION_6_0 static int sizeOf(int type) - { return QMetaType(type).sizeOf(); } + { return int(QMetaType(type).sizeOf()); } QT_DEPRECATED_VERSION_6_0 static TypeFlags typeFlags(int type) { return QMetaType(type).flags(); } diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index 11e4d9da399..a72215e8d65 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -333,7 +333,7 @@ constexpr inline uint qConstexprCountTrailingZeroBits(quint64 v) noexcept constexpr inline uint qConstexprCountTrailingZeroBits(quint8 v) noexcept { unsigned int c = 8; // c will be the number of zero bits on the right - v &= -signed(v); + v &= quint8(-signed(v)); if (v) c--; if (v & 0x0000000F) c -= 4; if (v & 0x00000033) c -= 2; @@ -344,7 +344,7 @@ constexpr inline uint qConstexprCountTrailingZeroBits(quint8 v) noexcept constexpr inline uint qConstexprCountTrailingZeroBits(quint16 v) noexcept { unsigned int c = 16; // c will be the number of zero bits on the right - v &= -signed(v); + v &= quint16(-signed(v)); if (v) c--; if (v & 0x000000FF) c -= 8; if (v & 0x00000F0F) c -= 4; diff --git a/src/corelib/tools/qtaggedpointer.h b/src/corelib/tools/qtaggedpointer.h index f6ce85eebc3..c12d5acdc2f 100644 --- a/src/corelib/tools/qtaggedpointer.h +++ b/src/corelib/tools/qtaggedpointer.h @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE namespace QtPrivate { - constexpr quint8 nextByteSize(quint8 bits) { return (bits + 7) / 8; } + constexpr quint8 nextByteSize(quint8 bits) { return quint8((bits + 7) / 8); } template struct TagInfo