Fix cppcheck warnings

This commit is contained in:
Lars Toenning
2023-04-16 21:02:55 +02:00
parent ac04aa3a63
commit 7ef0e6e1eb
28 changed files with 45 additions and 53 deletions

View File

@@ -183,7 +183,7 @@ namespace BlackCore::Afv::Clients
m_connection->connectTo(cid, password, callsign, client,
{ // this is the callback when the connection has been established
this, [=](bool authenticated) {
if (!myself) { return; }
if (!myself) { return; } // cppcheck-suppress knownConditionTrueFalse
// HF stations aliased
const QVector<StationDto> aliasedStations = m_connection->getAllAliasedStations();

View File

@@ -69,7 +69,7 @@ namespace BlackCore::Afv::Connection
{ this, [=](QNetworkReply *nwReply) {
// called in "this" thread
const QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> reply(nwReply);
if (!myself || isShuttingDown()) { return; }
if (!myself || isShuttingDown()) { return; } // cppcheck-suppress knownConditionTrueFalse
this->logRequestDuration(reply.data(), "authentication");
if (reply->error() != QNetworkReply::NoError)
@@ -278,7 +278,7 @@ namespace BlackCore::Afv::Connection
QPointer<CApiServerConnection> myself(this);
this->connectTo(m_username, m_password, m_client, m_networkVersion,
{ this, [=](bool authenticated) {
if (!myself) { return; }
if (!myself) { return; } // cppcheck-suppress knownConditionTrueFalse
CLogMessage(this).info(u"API server authenticated '%1': %2") << m_username << boolToYesNo(authenticated);
} });
}

View File

@@ -50,7 +50,7 @@ namespace BlackCore::Afv::Connection
{ // callback called when connected
this, [=](bool authenticated) {
// callback when connection has been established
if (!myself) { return; }
if (!myself) { return; } // cppcheck-suppress knownConditionTrueFalse
if (authenticated)
{

View File

@@ -32,7 +32,7 @@ namespace BlackCore::Afv::Model
{
loop.exec();
}
const QByteArray jsonData = reply->readAll();
const QByteArray jsonData = reply ? reply->readAll() : QByteArray {};
if (reply) { reply->deleteLater(); }
if (jsonData.isEmpty()) { return; }

View File

@@ -186,7 +186,7 @@ namespace BlackCore
eventLoop.stopWhen(m_fsdClient, &CFSDClient::flightPlanReceived, [=](const auto &cs, const auto &) { return cs == callsign; });
if (eventLoop.exec(1500))
{
if (!myself || !sApp || sApp->isShuttingDown()) { return CFlightPlan(); }
if (!myself || !sApp || sApp->isShuttingDown()) { return CFlightPlan(); } // cppcheck-suppress knownConditionTrueFalse
if (m_flightPlanCache.contains(callsign))
{
plan = m_flightPlanCache[callsign];

View File

@@ -644,7 +644,7 @@ namespace BlackCore::Context
if (!m_simulatorPlugin.first.isUnspecified())
{
ISimulator *simulator = m_simulatorPlugin.second;
if (simulator->isConnected())
if (simulator && simulator->isConnected())
{
// we are about to unload an connected simulator
this->updateMarkAllAsNotRendered(); // without plugin nothing can be rendered

View File

@@ -117,7 +117,7 @@ namespace BlackCore
// "retry" possible in some cases
do
{
if (ignoreCmdBootstrapUrl || !checkCmdBootstrapUrl || CNetworkUtils::canConnect(url, CNetworkUtils::getLongTimeoutMs()))
if (ignoreCmdBootstrapUrl || !checkCmdBootstrapUrl || CNetworkUtils::canConnect(url, CNetworkUtils::getLongTimeoutMs())) // cppcheck-suppress knownConditionTrueFalse
{
ok = true;
break;
@@ -308,7 +308,6 @@ namespace BlackCore
{
Q_ASSERT_X(!(webRead && localRead), Q_FUNC_INFO, "Local and web read together seems to be wrong");
CStatusMessageList msgs;
QPointer<CSetupReader> myself(this);
bool available = false;
if (webRead || localRead)