Skip to content

Commit c5c438f

Browse files
committed
all: fix gcc warnings and lints
1 parent 9bb2c04 commit c5c438f

File tree

11 files changed

+42
-16
lines changed

11 files changed

+42
-16
lines changed

Justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ lint-ci:
1212
lint-changed:
1313
git diff --name-only HEAD | grep "^.*\.cpp\$" | parallel -j$(nproc) --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
1414

15+
lint-staged:
16+
git diff --staged --name-only HEAD | grep "^.*\.cpp\$" | parallel -j$(nproc) --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
17+
1518
configure target='debug' *FLAGS='':
1619
cmake -GNinja -B {{builddir}} \
1720
-DCMAKE_BUILD_TYPE={{ if target == "debug" { "Debug" } else { "RelWithDebInfo" } }} \

src/core/logging.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,23 +313,32 @@ void ThreadLogging::init() {
313313

314314
if (logMfd != -1) {
315315
this->file = new QFile();
316-
this->file->open(logMfd, QFile::ReadWrite, QFile::AutoCloseHandle);
317-
this->fileStream.setDevice(this->file);
316+
317+
if (this->file->open(logMfd, QFile::ReadWrite, QFile::AutoCloseHandle)) {
318+
this->fileStream.setDevice(this->file);
319+
} else {
320+
qCCritical(logLogging) << "Failed to open early logging memfd.";
321+
}
318322
}
319323

320324
if (dlogMfd != -1) {
321325
crash::CrashInfo::INSTANCE.logFd = dlogMfd;
322326

323327
this->detailedFile = new QFile();
324328
// buffered by WriteBuffer
325-
this->detailedFile->open(dlogMfd, QFile::ReadWrite | QFile::Unbuffered, QFile::AutoCloseHandle);
326-
this->detailedWriter.setDevice(this->detailedFile);
329+
if (this->detailedFile
330+
->open(dlogMfd, QFile::ReadWrite | QFile::Unbuffered, QFile::AutoCloseHandle))
331+
{
332+
this->detailedWriter.setDevice(this->detailedFile);
327333

328-
if (!this->detailedWriter.writeHeader()) {
329-
qCCritical(logLogging) << "Could not write header for detailed logs.";
330-
this->detailedWriter.setDevice(nullptr);
331-
delete this->detailedFile;
332-
this->detailedFile = nullptr;
334+
if (!this->detailedWriter.writeHeader()) {
335+
qCCritical(logLogging) << "Could not write header for detailed logs.";
336+
this->detailedWriter.setDevice(nullptr);
337+
delete this->detailedFile;
338+
this->detailedFile = nullptr;
339+
}
340+
} else {
341+
qCCritical(logLogging) << "Failed to open early detailed logging memfd.";
333342
}
334343
}
335344

src/crash/handler.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ void CrashHandler::setRelaunchInfo(const RelaunchInfo& info) {
7777
}
7878

7979
QFile file;
80-
file.open(this->d->infoFd, QFile::ReadWrite);
80+
81+
if (!file.open(this->d->infoFd, QFile::ReadWrite)) {
82+
qCCritical(logCrashHandler
83+
) << "Failed to open instance info memfd, crash recovery will not work.";
84+
}
8185

8286
QDataStream ds(&file);
8387
ds << info;

src/crash/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ void qsCheckCrash(int argc, char** argv) {
161161
auto infoFd = qEnvironmentVariable("__QUICKSHELL_CRASH_INFO_FD").toInt();
162162

163163
QFile file;
164-
file.open(infoFd, QFile::ReadOnly, QFile::AutoCloseHandle);
164+
if (!file.open(infoFd, QFile::ReadOnly, QFile::AutoCloseHandle)) {
165+
qFatal() << "Failed to open instance info fd.";
166+
}
167+
165168
file.seek(0);
166169

167170
auto ds = QDataStream(&file);

src/launch/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ void checkCrashRelaunch(char** argv, QCoreApplication* coreApplication) {
3232
auto lastInfoFd = lastInfoFdStr.toInt();
3333

3434
QFile file;
35-
file.open(lastInfoFd, QFile::ReadOnly, QFile::AutoCloseHandle);
35+
if (!file.open(lastInfoFd, QFile::ReadOnly, QFile::AutoCloseHandle)) {
36+
qFatal() << "Failed to open crash info fd. Cannot restart.";
37+
}
38+
3639
file.seek(0);
3740

3841
auto ds = QDataStream(&file);

src/services/mpris/player.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ MprisPlayer::MprisPlayer(const QString& address, QObject* parent): QObject(paren
100100
} else return static_cast<qlonglong>(-1);
101101
});
102102

103-
this->bLengthSupported.setBinding([this]() { return this->bInternalLength != -1; });
103+
this->bLengthSupported.setBinding([this]() { return this->bInternalLength.value() != -1; });
104104

105105
this->bIsPlaying.setBinding([this]() {
106106
return this->bPlaybackState == MprisPlaybackState::Playing;

src/services/upower/device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ UPowerDevice::UPowerDevice(QObject* parent): QObject(parent) {
7373
return this->bType == UPowerDeviceType::Battery && this->bPowerSupply;
7474
});
7575

76-
this->bHealthSupported.setBinding([this]() { return this->bHealthPercentage != 0; });
76+
this->bHealthSupported.setBinding([this]() { return this->bHealthPercentage.value() != 0; });
7777
}
7878

7979
void UPowerDevice::init(const QString& path) {

src/services/upower/powerprofiles.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ QString DBusDataTransform<PowerProfile::Enum>::toWire(Data data) {
164164
case PowerProfile::PowerSaver: return QStringLiteral("power-saver");
165165
case PowerProfile::Balanced: return QStringLiteral("balanced");
166166
case PowerProfile::Performance: return QStringLiteral("performance");
167+
default: qFatal() << "Attempted to convert invalid power profile" << data << "to wire format.";
167168
}
168169
}
169170

src/wayland/wlr_layershell/wlr_layershell.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ WlrLayershell::WlrLayershell(QObject* parent): ProxyWindowBase(parent) {
2828
case Qt::BottomEdge: return this->bImplicitHeight + margins.top;
2929
case Qt::LeftEdge: return this->bImplicitWidth + margins.right;
3030
case Qt::RightEdge: return this->bImplicitWidth + margins.left;
31-
default: return 0;
3231
}
3332
}
33+
34+
return 0;
3435
});
3536

3637
this->bcExclusionEdge.setBinding([this] { return this->bAnchors.value().exclusionEdge(); });

src/x11/i3/ipc/connection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ QString I3IpcEvent::eventToString(EventCode event) {
532532
case EventCode::BarStateUpdate: return "bar_state_update"; break;
533533
case EventCode::Input: return "input"; break;
534534

535-
case EventCode::Unknown: return "unknown"; break;
535+
default: return "unknown"; break;
536536
}
537537
}
538538

0 commit comments

Comments
 (0)