all: fix gcc warnings

This commit is contained in:
outfoxxed 2024-11-05 13:31:24 -08:00
parent 92252c36a3
commit b528be9426
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
19 changed files with 57 additions and 22 deletions

View file

@ -369,6 +369,7 @@ void ThreadLogging::initFs() {
.l_whence = SEEK_SET,
.l_start = 0,
.l_len = 0,
.l_pid = 0,
};
if (fcntl(detailedFile->handle(), F_SETLK, &lock) != 0) { // NOLINT
@ -455,6 +456,8 @@ CompressedLogType compressedTypeOf(QtMsgType type) {
case QtCriticalMsg:
case QtFatalMsg: return CompressedLogType::Critical;
}
return CompressedLogType::Info; // unreachable under normal conditions
}
QtMsgType typeOfCompressed(CompressedLogType type) {
@ -464,6 +467,8 @@ QtMsgType typeOfCompressed(CompressedLogType type) {
case CompressedLogType::Warn: return QtWarningMsg;
case CompressedLogType::Critical: return QtCriticalMsg;
}
return QtInfoMsg; // unreachable under normal conditions
}
void WriteBuffer::setDevice(QIODevice* device) { this->device = device; }
@ -636,7 +641,7 @@ start:
if (!this->readVarInt(&secondDelta)) return false;
}
if (index < 0 || index >= this->recentMessages.size()) return false;
if (index >= this->recentMessages.size()) return false;
*slot = this->recentMessages.at(index);
this->lastMessageTime = this->lastMessageTime.addSecs(static_cast<qint64>(secondDelta));
slot->time = this->lastMessageTime;
@ -858,6 +863,7 @@ void LogFollower::FcntlWaitThread::run() {
.l_whence = SEEK_SET,
.l_start = 0,
.l_len = 0,
.l_pid = 0,
};
auto r = fcntl(this->follower->reader->file->handle(), F_SETLKW, &lock); // NOLINT

View file

@ -1,5 +1,6 @@
#pragma once
#include <bit>
#include <qabstractitemmodel.h>
#include <qcontainerfwd.h>
#include <qobject.h>
@ -85,11 +86,11 @@ public:
explicit ObjectModel(QObject* parent): UntypedObjectModel(parent) {}
[[nodiscard]] QVector<T*>& valueList() {
return *reinterpret_cast<QVector<T*>*>(&this->valuesList); // NOLINT
return *std::bit_cast<QVector<T*>*>(&this->valuesList);
}
[[nodiscard]] const QVector<T*>& valueList() const {
return *reinterpret_cast<const QVector<T*>*>(&this->valuesList); // NOLINT
return *std::bit_cast<const QVector<T*>*>(&this->valuesList);
}
void insertObject(T* object, qsizetype index = -1) {

View file

@ -242,6 +242,7 @@ void QsPaths::createLock() {
.l_whence = SEEK_SET,
.l_start = 0,
.l_len = 0,
.l_pid = 0,
};
if (fcntl(file->handle(), F_SETLK, &lock) != 0) { // NOLINT
@ -268,6 +269,7 @@ bool QsPaths::checkLock(const QString& path, InstanceLockInfo* info) {
.l_whence = SEEK_SET,
.l_start = 0,
.l_len = 0,
.l_pid = 0,
};
fcntl(file.handle(), F_GETLK, &lock); // NOLINT

View file

@ -1,10 +1,24 @@
#pragma once
#include <algorithm>
#include <type_traits>
#include <qlatin1stringview.h>
#include <qobject.h>
#include <qtclasshelpermacros.h>
#include <qtmetamacros.h>
template <size_t Length>
struct StringLiteral {
constexpr StringLiteral(const char (&str)[Length]) { // NOLINT
std::copy_n(str, Length, this->value);
}
constexpr operator const char*() const noexcept { return this->value; }
operator QLatin1StringView() const { return QLatin1String(this->value, Length); }
char value[Length]; // NOLINT
};
// NOLINTBEGIN
#define DROP_EMIT(object, func) \
DropEmitter(object, static_cast<void (*)(typeof(object))>([](typeof(object) o) { o->func(); }))