Skip to content

Commit 7ef0e6e

Browse files
committed
Fix cppcheck warnings
1 parent ac04aa3 commit 7ef0e6e

28 files changed

+45
-53
lines changed

src/blackcore/afv/clients/afvclient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ namespace BlackCore::Afv::Clients
183183
m_connection->connectTo(cid, password, callsign, client,
184184
{ // this is the callback when the connection has been established
185185
this, [=](bool authenticated) {
186-
if (!myself) { return; }
186+
if (!myself) { return; } // cppcheck-suppress knownConditionTrueFalse
187187

188188
// HF stations aliased
189189
const QVector<StationDto> aliasedStations = m_connection->getAllAliasedStations();

src/blackcore/afv/connection/apiserverconnection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace BlackCore::Afv::Connection
6969
{ this, [=](QNetworkReply *nwReply) {
7070
// called in "this" thread
7171
const QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> reply(nwReply);
72-
if (!myself || isShuttingDown()) { return; }
72+
if (!myself || isShuttingDown()) { return; } // cppcheck-suppress knownConditionTrueFalse
7373

7474
this->logRequestDuration(reply.data(), "authentication");
7575
if (reply->error() != QNetworkReply::NoError)
@@ -278,7 +278,7 @@ namespace BlackCore::Afv::Connection
278278
QPointer<CApiServerConnection> myself(this);
279279
this->connectTo(m_username, m_password, m_client, m_networkVersion,
280280
{ this, [=](bool authenticated) {
281-
if (!myself) { return; }
281+
if (!myself) { return; } // cppcheck-suppress knownConditionTrueFalse
282282
CLogMessage(this).info(u"API server authenticated '%1': %2") << m_username << boolToYesNo(authenticated);
283283
} });
284284
}

src/blackcore/afv/connection/clientconnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace BlackCore::Afv::Connection
5050
{ // callback called when connected
5151
this, [=](bool authenticated) {
5252
// callback when connection has been established
53-
if (!myself) { return; }
53+
if (!myself) { return; } // cppcheck-suppress knownConditionTrueFalse
5454

5555
if (authenticated)
5656
{

src/blackcore/afv/model/afvmapreader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace BlackCore::Afv::Model
3232
{
3333
loop.exec();
3434
}
35-
const QByteArray jsonData = reply->readAll();
35+
const QByteArray jsonData = reply ? reply->readAll() : QByteArray {};
3636
if (reply) { reply->deleteLater(); }
3737

3838
if (jsonData.isEmpty()) { return; }

src/blackcore/airspacemonitor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ namespace BlackCore
186186
eventLoop.stopWhen(m_fsdClient, &CFSDClient::flightPlanReceived, [=](const auto &cs, const auto &) { return cs == callsign; });
187187
if (eventLoop.exec(1500))
188188
{
189-
if (!myself || !sApp || sApp->isShuttingDown()) { return CFlightPlan(); }
189+
if (!myself || !sApp || sApp->isShuttingDown()) { return CFlightPlan(); } // cppcheck-suppress knownConditionTrueFalse
190190
if (m_flightPlanCache.contains(callsign))
191191
{
192192
plan = m_flightPlanCache[callsign];

src/blackcore/context/contextsimulatorimpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ namespace BlackCore::Context
644644
if (!m_simulatorPlugin.first.isUnspecified())
645645
{
646646
ISimulator *simulator = m_simulatorPlugin.second;
647-
if (simulator->isConnected())
647+
if (simulator && simulator->isConnected())
648648
{
649649
// we are about to unload an connected simulator
650650
this->updateMarkAllAsNotRendered(); // without plugin nothing can be rendered

src/blackcore/setupreader.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ namespace BlackCore
117117
// "retry" possible in some cases
118118
do
119119
{
120-
if (ignoreCmdBootstrapUrl || !checkCmdBootstrapUrl || CNetworkUtils::canConnect(url, CNetworkUtils::getLongTimeoutMs()))
120+
if (ignoreCmdBootstrapUrl || !checkCmdBootstrapUrl || CNetworkUtils::canConnect(url, CNetworkUtils::getLongTimeoutMs())) // cppcheck-suppress knownConditionTrueFalse
121121
{
122122
ok = true;
123123
break;
@@ -308,7 +308,6 @@ namespace BlackCore
308308
{
309309
Q_ASSERT_X(!(webRead && localRead), Q_FUNC_INFO, "Local and web read together seems to be wrong");
310310
CStatusMessageList msgs;
311-
QPointer<CSetupReader> myself(this);
312311

313312
bool available = false;
314313
if (webRead || localRead)

src/blackgui/components/settingsnetworkserverscomponent.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ namespace BlackGui::Components
9898
else
9999
{
100100
qFatal("Wrong sender");
101-
// cppcheck-suppress duplicateBreak
102101
return;
103102
}
104103

src/blackgui/loadindicator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace BlackGui
6262
if (processEvents && sGui)
6363
{
6464
sGui->processEventsToRefreshGui();
65-
if (!myself) { return -1; } // deleted in meantime (process events)
65+
if (!myself) { return -1; } // cppcheck-suppress knownConditionTrueFalse // deleted in meantime (process events)
6666
}
6767

6868
const int stopId = m_currentId++; // copy

src/blackgui/menus/menuaction.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,11 @@ namespace BlackGui::Menus
534534
}
535535
Q_ASSERT_X(subMenu, Q_FUNC_INFO, "Could not create sub menu");
536536

537-
subMenu->setParent(parentMenu);
537+
if (subMenu)
538+
{
539+
subMenu->setParent(parentMenu);
540+
}
541+
538542
if (pathDepth > 0 && subMenu)
539543
{
540544
subMenus.insert(key, subMenu);

0 commit comments

Comments
 (0)