mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-01 22:55:41 +08:00
Fix cppcheck and compiler warnings
This commit is contained in:
@@ -204,7 +204,7 @@ namespace BlackCore
|
||||
// restart timer, normally it should be started already, paranoia
|
||||
// as I run in "my thread" starting timer should be OK
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
QMutexLocker lock2(&m_mutex);
|
||||
if (m_voiceServerTimer) { m_voiceServerTimer->start(PositionUpdatesMs); }
|
||||
}
|
||||
m_retryConnectAttempt = 0;
|
||||
@@ -498,21 +498,21 @@ namespace BlackCore
|
||||
quint32 roundedFrequencyHz = static_cast<quint32>(qRound(frequencyHz / 1000.0)) * 1000;
|
||||
roundedFrequencyHz = this->getAliasFrequencyHz(roundedFrequencyHz);
|
||||
|
||||
bool updateTransceivers = false;
|
||||
bool update = false;
|
||||
{
|
||||
QMutexLocker lockTransceivers(&m_mutexTransceivers);
|
||||
if (m_transceivers.size() >= id + 1)
|
||||
{
|
||||
if (m_transceivers[id].frequencyHz != roundedFrequencyHz)
|
||||
{
|
||||
updateTransceivers = true;
|
||||
update = true;
|
||||
m_transceivers[id].frequencyHz = roundedFrequencyHz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// outside lock to avoid deadlock
|
||||
if (updateTransceivers)
|
||||
if (update)
|
||||
{
|
||||
this->updateTransceivers(false); // no frequency update
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace BlackCore
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
// posted in QAM thread, reply is nullptr if called from another thread
|
||||
QNetworkReply *reply = sApp->postToNetwork(request, CApplication::NoLogRequestId, QJsonDocument(obj).toJson(),
|
||||
sApp->postToNetwork(request, CApplication::NoLogRequestId, QJsonDocument(obj).toJson(),
|
||||
{
|
||||
this, [ = ](QNetworkReply * nwReply)
|
||||
{
|
||||
@@ -125,7 +125,6 @@ namespace BlackCore
|
||||
callback(m_isAuthenticated);
|
||||
}
|
||||
});
|
||||
Q_UNUSED(reply)
|
||||
}
|
||||
|
||||
PostCallsignResponseDto CApiServerConnection::addCallsign(const QString &callsign)
|
||||
@@ -176,7 +175,7 @@ namespace BlackCore
|
||||
QByteArray receivedData;
|
||||
|
||||
// posted in QAM thread, reply is nullptr if called from another thread
|
||||
QNetworkReply *reply = sApp->getFromNetwork(request,
|
||||
sApp->getFromNetwork(request,
|
||||
{
|
||||
this, [ =, &receivedData ](QNetworkReply * nwReply)
|
||||
{
|
||||
@@ -198,7 +197,6 @@ namespace BlackCore
|
||||
if (loop) { loop->exit(); }
|
||||
}
|
||||
});
|
||||
Q_UNUSED(reply)
|
||||
|
||||
if (loop) { loop->exec(); }
|
||||
return receivedData;
|
||||
@@ -212,7 +210,7 @@ namespace BlackCore
|
||||
QByteArray receivedData;
|
||||
|
||||
// posted in QAM thread, reply is nullptr if called from another thread
|
||||
QNetworkReply *reply = sApp->postToNetwork(request, CApplication::NoLogRequestId, data,
|
||||
sApp->postToNetwork(request, CApplication::NoLogRequestId, data,
|
||||
{
|
||||
this, [ =, &receivedData ](QNetworkReply * nwReply)
|
||||
{
|
||||
@@ -234,7 +232,6 @@ namespace BlackCore
|
||||
if (loop) { loop->exit(); }
|
||||
}
|
||||
});
|
||||
Q_UNUSED(reply)
|
||||
|
||||
if (loop) { loop->exec(); }
|
||||
return receivedData;
|
||||
|
||||
@@ -61,15 +61,15 @@ namespace BlackCore
|
||||
|
||||
if (authenticated)
|
||||
{
|
||||
const QString callsign = m_connection.getCallsign();
|
||||
m_connection.setTokens(m_apiServerConnection->addCallsign(callsign));
|
||||
const QString cs = m_connection.getCallsign();
|
||||
m_connection.setTokens(m_apiServerConnection->addCallsign(cs));
|
||||
m_connection.setTsAuthenticatedToNow();
|
||||
m_connection.createCryptoChannels();
|
||||
m_connection.setTsHeartbeatToNow();
|
||||
this->connectToVoiceServer();
|
||||
// taskServerConnectionCheck.Start();
|
||||
|
||||
CLogMessage(this).info(u"Connected: '%1' to voice server, socket open: %2") << callsign << boolToYesNo(m_udpSocket->isOpen());
|
||||
CLogMessage(this).info(u"Connected: '%1' to voice server, socket open: %2") << cs << boolToYesNo(m_udpSocket->isOpen());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -52,7 +52,6 @@ namespace BlackCore
|
||||
headerBuffer.close();
|
||||
const quint16 headerLength = static_cast<quint16>(headerBuffer.buffer().size());
|
||||
|
||||
const QByteArray dtoNameBuffer = T::getDtoName();
|
||||
const QByteArray dtoShortName = T::getShortDtoName();
|
||||
const quint16 dtoNameLength = static_cast<quint16>(dtoShortName.size());
|
||||
|
||||
|
||||
@@ -523,7 +523,7 @@ namespace BlackCore
|
||||
return rv;
|
||||
}
|
||||
|
||||
MatchingScriptReturnValues CAircraftMatcher::matchingScript(const QString &js, const CAircraftModel &inModel, const CAircraftModel &matchedModel, const CAircraftMatcherSetup &setup, const CAircraftModelList &modelSet, MatchingScript ms, CStatusMessageList *log)
|
||||
MatchingScriptReturnValues CAircraftMatcher::matchingScript(const QString &js, const CAircraftModel &inModel, const CAircraftModel &matchedModel, const CAircraftMatcherSetup &setup, const CAircraftModelList &modelSet, MatchingScript script, CStatusMessageList *log)
|
||||
{
|
||||
MatchingScriptReturnValues rv(inModel);
|
||||
QString logMessage;
|
||||
@@ -536,14 +536,14 @@ namespace BlackCore
|
||||
rv.runScript = true;
|
||||
|
||||
// matching script
|
||||
const bool msReverse = (ms == ReverseLookup);
|
||||
const bool msReverse = (script == ReverseLookup);
|
||||
const QString lf = msReverse ? setup.getMsReverseLookupFile() : setup.getMsMatchingStageFile();
|
||||
static const QString logFileR = CFileUtils::appendFilePaths(CDirectoryUtils::logDirectory(), "logMatchingScriptReverseLookup.log");
|
||||
static const QString logFileM = CFileUtils::appendFilePaths(CDirectoryUtils::logDirectory(), "logMatchingScriptMatchingStage.log");
|
||||
|
||||
if (log)
|
||||
{
|
||||
CLogUtilities::addLogDetailsToList(log, callsign, QStringLiteral("Matching script (%1): '%2'").arg(msToString(ms), lf));
|
||||
CLogUtilities::addLogDetailsToList(log, callsign, QStringLiteral("Matching script (%1): '%2'").arg(msToString(script), lf));
|
||||
CLogUtilities::addLogDetailsToList(log, callsign, QStringLiteral("Matching script input model (%1): '%2'").arg(inModel.toQString(true)));
|
||||
CLogUtilities::addLogDetailsToList(log, callsign, QStringLiteral("Matching script models: %1").arg(modelSet.coverageSummary()));
|
||||
}
|
||||
|
||||
@@ -1436,18 +1436,16 @@ namespace BlackCore
|
||||
bool canLikelySkipNearGround = correctedSituation.canLikelySkipNearGroundInterpolation();
|
||||
do
|
||||
{
|
||||
if (canLikelySkipNearGround || correctedSituation.hasGroundElevation()) { break; }
|
||||
|
||||
// set a defined state
|
||||
correctedSituation.resetGroundElevation();
|
||||
|
||||
// Check if we can bail out and ignore all elevation handling
|
||||
//
|
||||
// rational:
|
||||
// a) elevation handling is expensive, and might even requests elevation from sim.
|
||||
// b) elevations not needed pollute the cache with "useless" values
|
||||
//
|
||||
if (canLikelySkipNearGround) { break; }
|
||||
if (canLikelySkipNearGround || correctedSituation.hasGroundElevation()) { break; }
|
||||
|
||||
// set a defined state
|
||||
correctedSituation.resetGroundElevation();
|
||||
|
||||
// Guessing gives better values, also for smaller planes
|
||||
// and avoids unnecessary elevation fetching for low flying smaller GA aircraft
|
||||
|
||||
@@ -862,7 +862,6 @@ namespace BlackCore
|
||||
const CAircraftMatcherSetup setup = m_aircraftMatcher.getSetup();
|
||||
if (setup.doModelAddFailover())
|
||||
{
|
||||
const CCallsign cs = remoteAircraft.getCallsign();
|
||||
const int trial = m_failoverAddingCounts.value(cs, 0);
|
||||
if (trial < MaxModelAddedFailoverTrials)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BlackCore
|
||||
{
|
||||
namespace Fsd
|
||||
{
|
||||
ClientResponse::ClientResponse() : MessageBase()
|
||||
ClientResponse::ClientResponse()
|
||||
{ }
|
||||
|
||||
ClientResponse::ClientResponse(const QString &sender, const QString &receiver, ClientQueryType queryType, const QStringList &responseData)
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace BlackCore
|
||||
static QString pdu() { return "$CR"; }
|
||||
|
||||
//! Properties @{
|
||||
ClientQueryType m_queryType;
|
||||
ClientQueryType m_queryType {};
|
||||
QStringList m_responseData;
|
||||
//! @}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BlackCore
|
||||
{
|
||||
namespace Fsd
|
||||
{
|
||||
FlightPlan::FlightPlan() : MessageBase() { }
|
||||
FlightPlan::FlightPlan() { }
|
||||
|
||||
FlightPlan::FlightPlan(const QString &sender, const QString &receiver, FlightType flightType, const QString &aircraftIcaoType,
|
||||
int trueCruisingSpeed, const QString &depAirport, int estimatedDepTime, int actualDepTime, const QString &cruiseAlt,
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace BlackCore
|
||||
static QString pdu() { return "$FP"; }
|
||||
|
||||
//! Properties @{
|
||||
FlightType m_flightType;
|
||||
FlightType m_flightType {};
|
||||
QString m_aircraftIcaoType;
|
||||
int m_trueCruisingSpeed = 0;
|
||||
QString m_depAirport;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace BlackCore
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
RevBClientParts(const QString &sender, const QString &partsval1, const QString &partsval3, const QString &partsval2);
|
||||
RevBClientParts(const QString &sender, const QString &partsval1, const QString &partsval2, const QString &partsval3);
|
||||
|
||||
|
||||
//! Message converted to tokens
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BlackCore
|
||||
{
|
||||
namespace Fsd
|
||||
{
|
||||
ServerError::ServerError() : MessageBase()
|
||||
ServerError::ServerError()
|
||||
{ }
|
||||
|
||||
ServerError::ServerError(const QString &sender, const QString &receiver, ServerErrorCode errorCode, const QString &causingParameter, const QString &description)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace BlackCore
|
||||
//! @}
|
||||
|
||||
//! Properties @{
|
||||
ServerErrorCode m_errorNumber;
|
||||
ServerErrorCode m_errorNumber {};
|
||||
QString m_causingParameter;
|
||||
QString m_description;
|
||||
//! @}
|
||||
|
||||
@@ -431,8 +431,8 @@ namespace BlackCore
|
||||
{
|
||||
// no issue with cache
|
||||
m_updateInfoUrls = loadedSetup.getSwiftUpdateInfoFileUrls();
|
||||
const CStatusMessage m = CLogMessage(this).info(u"Loaded setup from '%1'") << urlString;
|
||||
emit this->setupLoadingMessages(m);
|
||||
const CStatusMessage m2 = CLogMessage(this).info(u"Loaded setup from '%1'") << urlString;
|
||||
emit this->setupLoadingMessages(m2);
|
||||
CLogMessage(this).info(u"Setup: Updated data cache in '%1'") << m_setup.getFilename();
|
||||
{
|
||||
QWriteLocker l(&m_lockSetup);
|
||||
|
||||
Reference in New Issue
Block a user