Fix cast warnings with MSVC

This commit is contained in:
Jonas Kvinge
2025-03-25 00:37:07 +01:00
parent d5281abb22
commit 5e031be42c
59 changed files with 207 additions and 207 deletions

View File

@@ -59,7 +59,7 @@ bool Copy(QIODevice *source, QIODevice *destination) {
if (!destination->open(QIODevice::WriteOnly)) return false;
const qint64 bytes = source->size();
unique_ptr<char[]> data(new char[bytes]);
unique_ptr<char[]> data(new char[static_cast<size_t>(bytes)]);
qint64 pos = 0;
qint64 bytes_read = 0;

View File

@@ -23,7 +23,7 @@
#include "scopedwchararray.h"
ScopedWCharArray::ScopedWCharArray(const QString &str)
: chars_(str.length()), data_(new wchar_t[chars_ + 1]) {
: chars_(str.length()), data_(new wchar_t[static_cast<size_t>(chars_ + 1)]) {
str.toWCharArray(data_.get());
data_[chars_] = '\0';
data_[static_cast<size_t>(chars_)] = '\0';
}

View File

@@ -36,7 +36,7 @@ class ScopedWCharArray {
explicit operator wchar_t *() const { return get(); }
qint64 characters() const { return chars_; }
qint64 bytes() const { return (chars_ + 1) * sizeof(wchar_t); }
qint64 bytes() const { return (chars_ + 1) * static_cast<qint64>(sizeof(wchar_t)); }
private:
Q_DISABLE_COPY(ScopedWCharArray)

View File

@@ -80,7 +80,7 @@ uint SqlHelper::ValueToUInt(const T &q, const int n) {
Q_ASSERT(n < q.count());
return q.value(n).isNull() || q.value(n).toInt() < 0 ? 0 : q.value(n).toInt();
return q.value(n).isNull() || q.value(n).toInt() < 0 ? 0 : q.value(n).toUInt();
}