summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-10-26 01:10:35 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-10-26 01:10:35 +0200
commitb28fa86e6ab633b2d3d9bfdb4642c661ff8c45fc (patch)
treee3500273bcd79fc9e6389e8dcc626607a2677678
parentMerge pull request #1215 from foxB612/fix-thumbnail-size (diff)
downloadnheko-b28fa86e6ab633b2d3d9bfdb4642c661ff8c45fc.tar.xz
Enable -Wconversion
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/AliasEditModel.cpp6
-rw-r--r--src/Cache.cpp6
-rw-r--r--src/CacheCryptoStructs.h4
-rw-r--r--src/CacheStructs.h4
-rw-r--r--src/ChatPage.cpp10
-rw-r--r--src/JdenticonProvider.cpp3
-rw-r--r--src/MxcImageProvider.cpp5
-rw-r--r--src/ReadReceiptsModel.cpp5
-rw-r--r--src/Utils.cpp62
-rw-r--r--src/dbus/NhekoDBusApi.cpp2
-rw-r--r--src/encryption/Olm.cpp2
-rw-r--r--src/main.cpp2
-rw-r--r--src/timeline/CommunitiesModel.cpp3
-rw-r--r--src/timeline/Permissions.cpp12
-rw-r--r--src/timeline/TimelineModel.cpp6
-rw-r--r--src/timeline/TimelineModel.h2
-rw-r--r--src/ui/MxcAnimatedImage.cpp2
-rw-r--r--src/ui/MxcMediaProxy.cpp2
-rw-r--r--src/ui/RoomSettings.cpp5
-rw-r--r--src/voip/CallManager.cpp10
-rw-r--r--src/voip/WebRTCSession.cpp12
-rw-r--r--third_party/blurhash/blurhash.cpp14
23 files changed, 102 insertions, 78 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2b456b1a..ef8d52bf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -275,6 +275,7 @@ if(NOT MSVC)
 		"${CMAKE_CXX_FLAGS} \
 		-Wall \
 		-Wextra \
+		-Wconversion \
 		-pedantic \
 		-fsized-deallocation \
 		-fdiagnostics-color=always \
diff --git a/src/AliasEditModel.cpp b/src/AliasEditModel.cpp
index aee42dd1..3f24a7c5 100644
--- a/src/AliasEditModel.cpp
+++ b/src/AliasEditModel.cpp
@@ -191,7 +191,7 @@ AliasEditingModel::makeCanonical(int row)
     auto moveAlias = aliases.at(row).alias;
 
     if (!aliasEvent.alias.empty()) {
-        for (qsizetype i = 0; i < aliases.size(); i++) {
+        for (int i = 0; i < aliases.size(); i++) {
             if (moveAlias == aliases[i].alias) {
                 if (aliases[i].canonical) {
                     aliases[i].canonical = false;
@@ -286,7 +286,7 @@ AliasEditingModel::toggleAdvertize(int row)
 void
 AliasEditingModel::updateAlias(std::string alias, std::string target)
 {
-    for (qsizetype i = 0; i < aliases.size(); i++) {
+    for (int i = 0; i < aliases.size(); i++) {
         auto &e = aliases[i];
         if (e.alias == alias) {
             e.published = (target == room_id);
@@ -300,7 +300,7 @@ AliasEditingModel::updatePublishedAliases(std::vector<std::string> advAliases)
 {
     for (const auto &advAlias : advAliases) {
         bool found = false;
-        for (qsizetype i = 0; i < aliases.size(); i++) {
+        for (int i = 0; i < aliases.size(); i++) {
             auto &alias = aliases[i];
             if (alias.alias == advAlias) {
                 alias.published = true;
diff --git a/src/Cache.cpp b/src/Cache.cpp
index a83b73f7..4f1fed1c 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -3777,9 +3777,9 @@ Cache::spaces()
                 std::string_view room_data;
                 if (roomsDb_.get(txn, space_id, room_data)) {
                     RoomInfo tmp = nlohmann::json::parse(std::move(room_data)).get<RoomInfo>();
-                    ret.insert(QString::fromUtf8(space_id.data(), (qsizetype)space_id.size()), tmp);
+                    ret.insert(QString::fromUtf8(space_id.data(), (int)space_id.size()), tmp);
                 } else {
-                    ret.insert(QString::fromUtf8(space_id.data(), (qsizetype)space_id.size()),
+                    ret.insert(QString::fromUtf8(space_id.data(), (int)space_id.size()),
                                std::nullopt);
                 }
             }
@@ -4938,7 +4938,7 @@ to_json(nlohmann::json &obj, const GroupSessionData &msg)
 void
 from_json(const nlohmann::json &obj, GroupSessionData &msg)
 {
-    msg.message_index = obj.at("message_index").get<uint64_t>();
+    msg.message_index = obj.at("message_index").get<uint32_t>();
     msg.timestamp     = obj.value("ts", 0ULL);
     msg.trusted       = obj.value("trust", true);
 
diff --git a/src/CacheCryptoStructs.h b/src/CacheCryptoStructs.h
index 04e852b4..99e563bd 100644
--- a/src/CacheCryptoStructs.h
+++ b/src/CacheCryptoStructs.h
@@ -33,7 +33,7 @@ struct DeviceKeysToMsgIndex
     // map from device key to message_index
     // Using the device id is safe because we check for reuse on device list updates
     // Using the device id makes our logic much easier to read.
-    std::map<std::string, uint64_t> deviceids;
+    std::map<std::string, uint32_t> deviceids;
 };
 
 struct SharedWithUsers
@@ -45,8 +45,8 @@ struct SharedWithUsers
 // Extra information associated with an outbound megolm session.
 struct GroupSessionData
 {
-    uint64_t message_index = 0;
     uint64_t timestamp     = 0;
+    uint32_t message_index = 0;
 
     // If we got the session via key sharing or forwarding, we can usually trust it.
     // If it came from asymmetric key backup, it is not trusted.
diff --git a/src/CacheStructs.h b/src/CacheStructs.h
index 459ced5a..1f035fee 100644
--- a/src/CacheStructs.h
+++ b/src/CacheStructs.h
@@ -93,8 +93,8 @@ struct RoomInfo
     //! Use the TimelineModel::lastMessage for an accurate timestamp.
     uint64_t approximate_last_modification_ts = 0;
 
-    uint16_t highlight_count    = 0;
-    uint16_t notification_count = 0;
+    uint64_t highlight_count    = 0;
+    uint64_t notification_count = 0;
 };
 
 void
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp
index 756ef425..2ea987c2 100644
--- a/src/ChatPage.cpp
+++ b/src/ChatPage.cpp
@@ -179,7 +179,8 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
         static unsigned int prevNotificationCount = 0;
         unsigned int notificationCount            = 0;
         for (const auto &room : sync.rooms.join) {
-            notificationCount += room.second.unread_notifications.notification_count;
+            notificationCount +=
+              static_cast<unsigned int>(room.second.unread_notifications.notification_count);
         }
 
         // HACK: If we had less notifications last time we checked, send an alert if the
@@ -1064,12 +1065,15 @@ ChatPage::verifyOneTimeKeyCountAfterStartup()
           }
 
           std::map<std::string, uint16_t> key_counts;
-          auto count = 0;
+          std::uint64_t count = 0;
           if (auto c = res.one_time_key_counts.find(mtx::crypto::SIGNED_CURVE25519);
               c == res.one_time_key_counts.end()) {
               key_counts[mtx::crypto::SIGNED_CURVE25519] = 0;
           } else {
-              key_counts[mtx::crypto::SIGNED_CURVE25519] = c->second;
+              key_counts[mtx::crypto::SIGNED_CURVE25519] =
+                c->second > std::numeric_limits<std::uint16_t>::max()
+                  ? std::numeric_limits<std::uint16_t>::max()
+                  : static_cast<std::uint16_t>(c->second);
               count                                      = c->second;
           }
 
diff --git a/src/JdenticonProvider.cpp b/src/JdenticonProvider.cpp
index 22d2b887..e9a7c883 100644
--- a/src/JdenticonProvider.cpp
+++ b/src/JdenticonProvider.cpp
@@ -104,7 +104,8 @@ JdenticonRunnable::run()
     painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
 
     try {
-        QSvgRenderer renderer{jdenticon->generate(m_key, m_requestedSize.width()).toUtf8()};
+        QSvgRenderer renderer{
+          jdenticon->generate(m_key, static_cast<std::uint16_t>(m_requestedSize.width())).toUtf8()};
         renderer.render(&painter);
     } catch (std::exception &e) {
         nhlog::ui()->error(
diff --git a/src/MxcImageProvider.cpp b/src/MxcImageProvider.cpp
index 3022ca3d..26ffb934 100644
--- a/src/MxcImageProvider.cpp
+++ b/src/MxcImageProvider.cpp
@@ -169,8 +169,9 @@ MxcImageProvider::download(const QString &id,
 
         mtx::http::ThumbOpts opts;
         opts.mxc_url = "mxc://" + id.toStdString();
-        opts.width   = requestedSize.width() > 0 ? requestedSize.width() : -1;
-        opts.height  = requestedSize.height() > 0 ? requestedSize.height() : -1;
+        opts.width   = static_cast<uint8_t>(requestedSize.width() > 0 ? requestedSize.width() : -1);
+        opts.height =
+          static_cast<uint8_t>(requestedSize.height() > 0 ? requestedSize.height() : -1);
         opts.method  = crop ? "crop" : "scale";
         http::client()->get_thumbnail(
           opts,
diff --git a/src/ReadReceiptsModel.cpp b/src/ReadReceiptsModel.cpp
index 2b1cdc74..f9de970b 100644
--- a/src/ReadReceiptsModel.cpp
+++ b/src/ReadReceiptsModel.cpp
@@ -85,8 +85,9 @@ ReadReceiptsModel::addUsers(
     auto newReceipts = users.size() - readReceipts_.size();
 
     if (newReceipts > 0) {
-        beginInsertRows(
-          QModelIndex{}, readReceipts_.size(), readReceipts_.size() + newReceipts - 1);
+        beginInsertRows(QModelIndex{},
+                        static_cast<int>(readReceipts_.size()),
+                        static_cast<int>(readReceipts_.size() + newReceipts - 1));
 
         for (const auto &user : users) {
             QPair<QString, QDateTime> item = {QString::fromStdString(user.second),
diff --git a/src/Utils.cpp b/src/Utils.cpp
index b92c6cce..c782fa48 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -354,8 +354,8 @@ utils::scaleImageToPixmap(const QImage &img, int size)
 
     // Deprecated in 5.13: const double sz =
     //  std::ceil(QApplication::desktop()->screen()->devicePixelRatioF() * (double)size);
-    const double sz =
-      std::ceil(QGuiApplication::primaryScreen()->devicePixelRatio() * (double)size);
+    const int sz = static_cast<int>(
+      std::ceil(QGuiApplication::primaryScreen()->devicePixelRatio() * (double)size));
     return QPixmap::fromImage(img.scaled(sz, sz, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
 }
 
@@ -376,8 +376,8 @@ utils::scaleDown(uint64_t maxWidth, uint64_t maxHeight, const QPixmap &source)
         w = source.width();
         h = source.height();
     } else {
-        w = source.width() * minAspectRatio;
-        h = source.height() * minAspectRatio;
+        w = static_cast<int>(static_cast<double>(source.width()) * minAspectRatio);
+        h = static_cast<int>(static_cast<double>(source.height()) * minAspectRatio);
     }
 
     return source.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
@@ -452,7 +452,7 @@ utils::escapeBlacklistedHtml(const QString &rawStr)
     const auto end = data.cend();
     for (auto pos = data.cbegin(); pos < end;) {
         auto tagStart = std::find(pos, end, '<');
-        buffer.append(pos, tagStart - pos);
+        buffer.append(pos, static_cast<int>(tagStart - pos));
         if (tagStart == end)
             break;
 
@@ -460,14 +460,15 @@ utils::escapeBlacklistedHtml(const QString &rawStr)
         const auto tagNameEnd =
           std::find_first_of(tagNameStart, end, tagNameEnds.begin(), tagNameEnds.end());
 
-        if (allowedTags.find(QByteArray(tagNameStart, tagNameEnd - tagNameStart).toLower()) ==
+        if (allowedTags.find(
+              QByteArray(tagNameStart, static_cast<int>(tagNameEnd - tagNameStart)).toLower()) ==
             allowedTags.end()) {
             // not allowed -> escape
             buffer.append("&lt;");
             pos = tagNameStart;
             continue;
         } else {
-            buffer.append(tagStart, tagNameEnd - tagStart);
+            buffer.append(tagStart, static_cast<int>(tagNameEnd - tagStart));
 
             pos = tagNameEnd;
 
@@ -492,7 +493,8 @@ utils::escapeBlacklistedHtml(const QString &rawStr)
                     auto attrEnd = std::find_first_of(
                       attrStart, attrsEnd, attrNameEnds.begin(), attrNameEnds.end());
 
-                    auto attrName = QByteArray(attrStart, attrEnd - attrStart).toLower();
+                    auto attrName =
+                      QByteArray(attrStart, static_cast<int>(attrEnd - attrStart)).toLower();
 
                     auto sanitizeValue = [&attrName](QByteArray val) {
                         if (attrName == QByteArrayLiteral("src") && !val.startsWith("mxc://"))
@@ -520,8 +522,8 @@ utils::escapeBlacklistedHtml(const QString &rawStr)
                                     if (valueEnd == attrsEnd)
                                         break;
 
-                                    auto val =
-                                      sanitizeValue(QByteArray(attrStart, valueEnd - attrStart));
+                                    auto val  = sanitizeValue(QByteArray(
+                                      attrStart, static_cast<int>(valueEnd - attrStart)));
                                     attrStart = consumeSpaces(valueEnd + 1);
                                     if (!val.isEmpty()) {
                                         buffer.append(' ');
@@ -537,8 +539,8 @@ utils::escapeBlacklistedHtml(const QString &rawStr)
                                     if (valueEnd == attrsEnd)
                                         break;
 
-                                    auto val =
-                                      sanitizeValue(QByteArray(attrStart, valueEnd - attrStart));
+                                    auto val  = sanitizeValue(QByteArray(
+                                      attrStart, static_cast<int>(valueEnd - attrStart)));
                                     attrStart = consumeSpaces(valueEnd + 1);
                                     if (!val.isEmpty()) {
                                         buffer.append(' ');
@@ -553,8 +555,8 @@ utils::escapeBlacklistedHtml(const QString &rawStr)
                                                                        attrsEnd,
                                                                        attrValueEnds.begin(),
                                                                        attrValueEnds.end());
-                                    auto val =
-                                      sanitizeValue(QByteArray(attrStart, valueEnd - attrStart));
+                                    auto val      = sanitizeValue(QByteArray(
+                                      attrStart, static_cast<int>(valueEnd - attrStart)));
                                     attrStart = consumeSpaces(valueEnd);
 
                                     if (val.contains('"'))
@@ -772,15 +774,15 @@ utils::generateContrastingHexColor(const QString &input, const QColor &backgroun
     auto hash = hashQString(input);
     // create a hue value based on the hash of the input.
     // Adapted to make Nico blue
-    auto userHue =
-      static_cast<int>(static_cast<double>(hash - static_cast<uint32_t>(0x60'00'00'00)) /
-                       std::numeric_limits<uint32_t>::max() * 360.);
+    auto userHue = static_cast<double>(hash - static_cast<uint32_t>(0x60'00'00'00)) /
+                   std::numeric_limits<uint32_t>::max() * 360.;
     // start with moderate saturation and lightness values.
-    auto sat       = 230;
-    auto lightness = 125;
+    auto sat       = 230.;
+    auto lightness = 125.;
 
     // converting to a QColor makes the luminance calc easier.
-    QColor inputColor = QColor::fromHsl(userHue, sat, lightness);
+    QColor inputColor = QColor::fromHsl(
+      static_cast<int>(userHue), static_cast<int>(sat), static_cast<int>(lightness));
 
     // calculate the initial luminance and contrast of the
     // generated color.  It's possible that no additional
@@ -798,7 +800,9 @@ utils::generateContrastingHexColor(const QString &input, const QColor &backgroun
         if (lightness >= 242 || lightness <= 13) {
             qreal newSat = qBound(26.0, sat * 1.25, 242.0);
 
-            inputColor.setHsl(userHue, qFloor(newSat), lightness);
+            inputColor.setHsl(static_cast<int>(userHue),
+                              static_cast<int>(qFloor(newSat)),
+                              static_cast<int>(lightness));
             auto tmpLum         = luminance(inputColor);
             auto higherContrast = computeContrast(tmpLum, backgroundLum);
             if (higherContrast > contrast) {
@@ -806,7 +810,9 @@ utils::generateContrastingHexColor(const QString &input, const QColor &backgroun
                 sat      = newSat;
             } else {
                 newSat = qBound(26.0, sat / 1.25, 242.0);
-                inputColor.setHsl(userHue, qFloor(newSat), lightness);
+                inputColor.setHsl(static_cast<int>(userHue),
+                                  static_cast<int>(qFloor(newSat)),
+                                  static_cast<int>(lightness));
                 tmpLum             = luminance(inputColor);
                 auto lowerContrast = computeContrast(tmpLum, backgroundLum);
                 if (lowerContrast > contrast) {
@@ -817,7 +823,9 @@ utils::generateContrastingHexColor(const QString &input, const QColor &backgroun
         } else {
             qreal newLightness = qBound(13.0, lightness * 1.25, 242.0);
 
-            inputColor.setHsl(userHue, sat, qFloor(newLightness));
+            inputColor.setHsl(static_cast<int>(userHue),
+                              static_cast<int>(sat),
+                              static_cast<int>(qFloor(newLightness)));
 
             auto tmpLum         = luminance(inputColor);
             auto higherContrast = computeContrast(tmpLum, backgroundLum);
@@ -829,7 +837,9 @@ utils::generateContrastingHexColor(const QString &input, const QColor &backgroun
                 // otherwise, try going the other way instead.
             } else {
                 newLightness = qBound(13.0, lightness / 1.25, 242.0);
-                inputColor.setHsl(userHue, sat, qFloor(newLightness));
+                inputColor.setHsl(static_cast<int>(userHue),
+                                  static_cast<int>(sat),
+                                  static_cast<int>(qFloor(newLightness)));
                 tmpLum             = luminance(inputColor);
                 auto lowerContrast = computeContrast(tmpLum, backgroundLum);
                 if (lowerContrast > contrast) {
@@ -888,8 +898,8 @@ utils::centerWidget(QWidget *widget, QWindow *parent)
     }
 
     auto findCenter = [childRect = widget->rect()](QRect hostRect) -> QPoint {
-        return QPoint(hostRect.center().x() - (childRect.width() * 0.5),
-                      hostRect.center().y() - (childRect.height() * 0.5));
+        return QPoint(static_cast<int>(hostRect.center().x() - (childRect.width() * 0.5)),
+                      static_cast<int>(hostRect.center().y() - (childRect.height() * 0.5)));
     };
     widget->move(findCenter(QGuiApplication::primaryScreen()->geometry()));
 }
diff --git a/src/dbus/NhekoDBusApi.cpp b/src/dbus/NhekoDBusApi.cpp
index 47fdca69..2367c27b 100644
--- a/src/dbus/NhekoDBusApi.cpp
+++ b/src/dbus/NhekoDBusApi.cpp
@@ -186,7 +186,7 @@ operator<<(QDBusArgument &arg, const QImage &image)
     int channels = i.hasAlphaChannel() ? 4 : 3;
     arg << i.depth() / channels;
     arg << channels;
-    arg << QByteArray(reinterpret_cast<const char *>(i.bits()), i.sizeInBytes());
+    arg << QByteArray(reinterpret_cast<const char *>(i.bits()), static_cast<int>(i.sizeInBytes()));
     arg.endStructure();
 
     return arg;
diff --git a/src/encryption/Olm.cpp b/src/encryption/Olm.cpp
index 03d0e983..7ada2f92 100644
--- a/src/encryption/Olm.cpp
+++ b/src/encryption/Olm.cpp
@@ -1144,7 +1144,7 @@ handle_key_request_message(const mtx::events::DeviceEvent<mtx::events::msg::KeyR
     }
 
     bool shouldSeeKeys    = false;
-    uint64_t minimumIndex = -1;
+    uint32_t minimumIndex = -1;
     if (sessionData->currently.keys.count(req.sender)) {
         if (sessionData->currently.keys.at(req.sender)
               .deviceids.count(req.content.requesting_device_id)) {
diff --git a/src/main.cpp b/src/main.cpp
index 83b4657a..3937c6b7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -61,7 +61,7 @@ stacktraceHandler(int signum)
     // see
     // https://stackoverflow.com/questions/77005/how-to-automatically-generate-a-stacktrace-when-my-program-crashes/77336#77336
     void *array[50];
-    size_t size;
+    int size;
 
     // get void*'s for all entries on the stack
     size = backtrace(array, 50);
diff --git a/src/timeline/CommunitiesModel.cpp b/src/timeline/CommunitiesModel.cpp
index ef023cee..96d090f7 100644
--- a/src/timeline/CommunitiesModel.cpp
+++ b/src/timeline/CommunitiesModel.cpp
@@ -153,7 +153,8 @@ CommunitiesModel::data(const QModelIndex &index, int role) const
             int count = 0;
             auto end  = spaceOrder_.lastChild(index.row() - 2);
             for (int i = index.row() - 2; i <= end; i++)
-                count += spaceOrder_.tree[i].notificationCounts.notification_count;
+                count +=
+                  static_cast<int>(spaceOrder_.tree[i].notificationCounts.notification_count);
             return count;
         }
         case CommunitiesModel::Roles::HasLoudNotification: {
diff --git a/src/timeline/Permissions.cpp b/src/timeline/Permissions.cpp
index 9fa833b7..78bb3cf6 100644
--- a/src/timeline/Permissions.cpp
+++ b/src/timeline/Permissions.cpp
@@ -66,24 +66,24 @@ Permissions::canSend(int eventType)
 int
 Permissions::defaultLevel()
 {
-    return pl.users_default;
+    return static_cast<int>(pl.users_default);
 }
 int
 Permissions::redactLevel()
 {
-    return pl.redact;
+    return static_cast<int>(pl.redact);
 }
 int
 Permissions::changeLevel(int eventType)
 {
-    return pl.state_level(to_string(
-      qml_mtx_events::fromRoomEventType(static_cast<qml_mtx_events::EventType>(eventType))));
+    return static_cast<int>(pl.state_level(to_string(
+      qml_mtx_events::fromRoomEventType(static_cast<qml_mtx_events::EventType>(eventType)))));
 }
 int
 Permissions::sendLevel(int eventType)
 {
-    return pl.event_level(to_string(
-      qml_mtx_events::fromRoomEventType(static_cast<qml_mtx_events::EventType>(eventType))));
+    return static_cast<int>(pl.event_level(to_string(
+      qml_mtx_events::fromRoomEventType(static_cast<qml_mtx_events::EventType>(eventType)))));
 }
 
 bool
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 5ffd7415..6cf361aa 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -679,7 +679,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
         if (w == 0)
             w = 1;
 
-        double prop = media_height(event) / (double)w;
+        double prop = (double)media_height(event) / (double)w;
 
         return {prop > 0 ? prop : 1.};
     }
@@ -2881,7 +2881,7 @@ TimelineModel::pinnedMessages() const
         return {};
 
     QStringList list;
-    list.reserve((qsizetype)pinned->content.pinned.size());
+    list.reserve((int)pinned->content.pinned.size());
     for (const auto &p : pinned->content.pinned)
         list.push_back(QString::fromStdString(p));
 
@@ -2912,7 +2912,7 @@ TimelineModel::widgetLinks() const
         theme.clear();
     user = QUrl::toPercentEncoding(user);
 
-    list.reserve((qsizetype)evs.size());
+    list.reserve((int)evs.size());
     for (const auto &p : evs) {
         auto url = QString::fromStdString(p.content.url);
 
diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index 2a04c9c9..8bf18f19 100644
--- a/src/timeline/TimelineModel.h
+++ b/src/timeline/TimelineModel.h
@@ -406,7 +406,7 @@ public slots:
     RoomSummary *parentSpace();
 
     bool hasMentions() const { return highlight_count > 0; }
-    int notificationCount() const { return notification_count; }
+    int notificationCount() const { return static_cast<int>(notification_count); }
 
     QString scrollTarget() const;
 
diff --git a/src/ui/MxcAnimatedImage.cpp b/src/ui/MxcAnimatedImage.cpp
index 8ecea7d9..7f7210e3 100644
--- a/src/ui/MxcAnimatedImage.cpp
+++ b/src/ui/MxcAnimatedImage.cpp
@@ -82,7 +82,7 @@ MxcAnimatedImage::startDownload()
                 std::string temp(ba.constData(), ba.size());
                 temp =
                   mtx::crypto::to_string(mtx::crypto::decrypt_file(temp, encryptionInfo.value()));
-                buffer.setData(temp.data(), temp.size());
+                buffer.setData(temp.data(), static_cast<int>(temp.size()));
             } else {
                 buffer.setData(device.readAll());
             }
diff --git a/src/ui/MxcMediaProxy.cpp b/src/ui/MxcMediaProxy.cpp
index 3676a74e..dadd4478 100644
--- a/src/ui/MxcMediaProxy.cpp
+++ b/src/ui/MxcMediaProxy.cpp
@@ -122,7 +122,7 @@ MxcMediaProxy::startDownload()
             QByteArray ba = device.readAll();
             std::string temp(ba.constData(), ba.size());
             temp = mtx::crypto::to_string(mtx::crypto::decrypt_file(temp, encryptionInfo.value()));
-            buffer.setData(temp.data(), temp.size());
+            buffer.setData(temp.data(), static_cast<int>(temp.size()));
         } else {
             buffer.setData(device.readAll());
         }
diff --git a/src/ui/RoomSettings.cpp b/src/ui/RoomSettings.cpp
index 546cda29..67be0bbb 100644
--- a/src/ui/RoomSettings.cpp
+++ b/src/ui/RoomSettings.cpp
@@ -132,7 +132,7 @@ RoomSettings::roomAvatarUrl()
 int
 RoomSettings::memberCount() const
 {
-    return info_.member_count;
+    return static_cast<int>(info_.member_count);
 }
 
 void
@@ -180,7 +180,8 @@ QStringList
 RoomSettings::allowedRooms() const
 {
     QStringList rooms;
-    rooms.reserve(accessRules_.allow.size());
+    assert(accessRules_.allow.size() < std::numeric_limits<int>::max());
+    rooms.reserve(static_cast<int>(accessRules_.allow.size()));
     for (const auto &e : accessRules_.allow) {
         if (e.type == mtx::events::state::JoinAllowanceType::RoomMembership)
             rooms.push_back(QString::fromStdString(e.room_id));
diff --git a/src/voip/CallManager.cpp b/src/voip/CallManager.cpp
index 5e711499..1bb1700f 100644
--- a/src/voip/CallManager.cpp
+++ b/src/voip/CallManager.cpp
@@ -124,10 +124,10 @@ CallManager::CallManager(QObject *parent)
           // Request new credentials close to expiry
           // See https://tools.ietf.org/html/draft-uberti-behave-turn-rest-00
           turnURIs_    = getTurnURIs(res);
-          uint32_t ttl = std::max(res.ttl, UINT32_C(3600));
+          uint32_t ttl = std::max(res.ttl, std::uint32_t{3600});
           if (res.ttl < 3600)
               nhlog::net()->warn("Setting ttl to 1 hour");
-          turnServerTimer_.setInterval(ttl * 1000 * 0.9);
+          turnServerTimer_.setInterval(std::chrono::seconds(ttl) * 10 / 9);
       });
 
     connect(&session_, &WebRTCSession::stateChanged, this, [this](webrtc::State state) {
@@ -728,7 +728,8 @@ CallManager::devices(bool isVideo) const
       isVideo ? UserSettings::instance()->camera() : UserSettings::instance()->microphone();
     std::vector<std::string> devices =
       CallDevices::instance().names(isVideo, defaultDevice.toStdString());
-    ret.reserve(devices.size());
+    assert(devices.size() < std::numeric_limits<int>::max());
+    ret.reserve(static_cast<int>(devices.size()));
     std::transform(devices.cbegin(), devices.cend(), std::back_inserter(ret), [](const auto &d) {
         return QString::fromStdString(d);
     });
@@ -867,7 +868,8 @@ CallManager::windowList()
     }
 #endif
     QStringList ret;
-    ret.reserve(windows_.size());
+    assert(windows_.size() < std::numeric_limits<int>::max());
+    ret.reserve(static_cast<int>(windows_.size()));
     for (const auto &w : windows_)
         ret.append(w.first);
 
diff --git a/src/voip/WebRTCSession.cpp b/src/voip/WebRTCSession.cpp
index b3e6bf26..706a69d9 100644
--- a/src/voip/WebRTCSession.cpp
+++ b/src/voip/WebRTCSession.cpp
@@ -141,7 +141,8 @@ parseSDP(const std::string &sdp, GstWebRTCSDPType type)
 {
     GstSDPMessage *msg;
     gst_sdp_message_new(&msg);
-    if (gst_sdp_message_parse_buffer((guint8 *)sdp.c_str(), sdp.size(), msg) == GST_SDP_OK) {
+    if (gst_sdp_message_parse_buffer((guint8 *)sdp.c_str(), static_cast<guint>(sdp.size()), msg) ==
+        GST_SDP_OK) {
         return gst_webrtc_session_description_new(type, msg);
     } else {
         nhlog::ui()->error("WebRTC: failed to parse remote session description");
@@ -371,9 +372,12 @@ getResolution(GstElement *pipe, const gchar *elementName, const gchar *padName)
 std::pair<int, int>
 getPiPDimensions(const std::pair<int, int> &resolution, int fullWidth, double scaleFactor)
 {
-    int pipWidth  = fullWidth * scaleFactor;
-    int pipHeight = static_cast<double>(resolution.second) / resolution.first * pipWidth;
-    return {pipWidth, pipHeight};
+    double pipWidth  = fullWidth * scaleFactor;
+    double pipHeight = static_cast<double>(resolution.second) / resolution.first * pipWidth;
+    return {
+      static_cast<int>(std::ceil(pipWidth)),
+      static_cast<int>(std::ceil(pipHeight)),
+    };
 }
 
 void
diff --git a/third_party/blurhash/blurhash.cpp b/third_party/blurhash/blurhash.cpp
index 78f72f9b..7eb9c827 100644
--- a/third_party/blurhash/blurhash.cpp
+++ b/third_party/blurhash/blurhash.cpp
@@ -4,6 +4,7 @@
 #include <array>
 #include <cassert>
 #include <cmath>
+#include <numbers>
 #include <stdexcept>
 
 #ifdef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
@@ -17,9 +18,6 @@
 using namespace std::literals;
 
 namespace {
-template<class T>
-T pi = 3.14159265358979323846;
-
 constexpr std::array<char, 84> int_to_b83{
   "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~"};
 
@@ -93,7 +91,7 @@ decode83(std::string_view value)
 float
 decodeMaxAC(int quantizedMaxAC) noexcept
 {
-        return (quantizedMaxAC + 1) / 166.;
+        return static_cast<float>(quantizedMaxAC + 1) / 166.f;
 }
 
 float
@@ -123,7 +121,7 @@ srgbToLinear(int value) noexcept
                         return std::pow((x + 0.055f) / 1.055f, 2.4f);
         };
 
-        return srgbToLinearF(value / 255.f);
+        return srgbToLinearF(static_cast<float>(value) / 255.f);
 }
 
 int
@@ -234,7 +232,7 @@ std::vector<float>
 bases_for(size_t dimension, size_t components)
 {
         std::vector<float> bases(dimension * components, 0.f);
-        auto scale = pi<float> / float(dimension);
+        auto scale = std::numbers::pi_v<float> / float(dimension);
         for (size_t x = 0; x < dimension; x++) {
                 for (size_t nx = 0; nx < size_t(components); nx++) {
                         bases[x * components + nx] = std::cos(scale * float(nx * x));
@@ -323,7 +321,7 @@ encode(unsigned char *image, size_t width, size_t height, int components_x, int
                                      srgbToLinear(image[3 * x + 2 + y * width * 3])};
 
                         // other half of normalization.
-                        linear *= 1.f / width;
+                        linear *= 1.f / static_cast<float>(width);
 
                         for (size_t ny = 0; ny < size_t(components_y); ny++) {
                                 for (size_t nx = 0; nx < size_t(components_x); nx++) {
@@ -339,7 +337,7 @@ encode(unsigned char *image, size_t width, size_t height, int components_x, int
         // too far outside the float range.
         for (size_t i = 0; i < factors.size(); i++) {
                 float normalisation = (i == 0) ? 1 : 2;
-                float scale         = normalisation / (height);
+                float scale         = normalisation / static_cast<float>(height);
                 factors[i] *= scale;
         }