Q_UNREACHABLE fix, minor style adjustments

This commit is contained in:
Klaus Basan
2020-01-18 20:06:47 +01:00
parent 785dc7f016
commit bd39b0638c
4 changed files with 69 additions and 40 deletions

View File

@@ -63,7 +63,7 @@ namespace BlackCore
{ {
BlackMisc::CLogMessage(static_cast<PilotDataUpdate *>(nullptr)).debug(u"Wrong number of arguments."); BlackMisc::CLogMessage(static_cast<PilotDataUpdate *>(nullptr)).debug(u"Wrong number of arguments.");
return {}; return {};
}; }
double pitch = 0.0; double pitch = 0.0;
double bank = 0.0; double bank = 0.0;

View File

@@ -7,6 +7,7 @@
*/ */
#include "serializer.h" #include "serializer.h"
#include "blackmisc/verify.h"
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
@@ -35,8 +36,9 @@ namespace BlackCore
case AtcRating::Supervisor: return "11"; case AtcRating::Supervisor: return "11";
case AtcRating::Administrator: return "12"; case AtcRating::Administrator: return "12";
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
return {}; return "0";
} }
template<> template<>
@@ -54,7 +56,11 @@ namespace BlackCore
else if (str == "10") return AtcRating::Instructor3; else if (str == "10") return AtcRating::Instructor3;
else if (str == "11") return AtcRating::Supervisor; else if (str == "11") return AtcRating::Supervisor;
else if (str == "12") return AtcRating::Administrator; else if (str == "12") return AtcRating::Administrator;
else return AtcRating::Unknown;
// we should NOT get here
const QByteArray msg = QStringLiteral("Unknown ATC rating '%1'").arg(str).toLatin1();
BLACK_AUDIT_X(false, Q_FUNC_INFO, msg.constData());
return AtcRating::Unknown;
} }
template<> template<>
@@ -69,8 +75,9 @@ namespace BlackCore
case PilotRating::Instructor: return "4"; case PilotRating::Instructor: return "4";
case PilotRating::Supervisor: return "5"; case PilotRating::Supervisor: return "5";
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
return {}; return "0";
} }
template<> template<>
@@ -82,8 +89,11 @@ namespace BlackCore
else if (str == "3") return PilotRating::IFR; else if (str == "3") return PilotRating::IFR;
else if (str == "4") return PilotRating::Instructor; else if (str == "4") return PilotRating::Instructor;
else if (str == "5") return PilotRating::Supervisor; else if (str == "5") return PilotRating::Supervisor;
Q_UNREACHABLE();
return {}; // we should NOT get here
const QByteArray msg = QStringLiteral("Unknown Pilot rating '%1'").arg(str).toLatin1();
BLACK_AUDIT_X(false, Q_FUNC_INFO, msg.constData());
return PilotRating::Unknown;
} }
template<> template<>
@@ -111,8 +121,9 @@ namespace BlackCore
case SimType::P3Dv3: return "30"; case SimType::P3Dv3: return "30";
case SimType::P3Dv4: return "30"; case SimType::P3Dv4: return "30";
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
return {}; return "0";
} }
template<> template<>
@@ -135,7 +146,12 @@ namespace BlackCore
else if (str == "25") return SimType::FlightGear; else if (str == "25") return SimType::FlightGear;
// Still ambigious which P3D version. No standard defined yet. // Still ambigious which P3D version. No standard defined yet.
else if (str == "30") return SimType::P3Dv4; else if (str == "30") return SimType::P3Dv4;
else return SimType::Unknown;
// we should NOT get here
const QByteArray msg = QStringLiteral("Unknown SimType '%1'").arg(str).toLatin1();
BLACK_AUDIT_X(false, Q_FUNC_INFO, msg.constData());
return SimType::Unknown;
} }
template<> template<>
@@ -153,6 +169,7 @@ namespace BlackCore
case CFacilityType::CTR: return "6"; case CFacilityType::CTR: return "6";
case CFacilityType::Unknown: return {}; case CFacilityType::Unknown: return {};
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
return {}; return {};
} }
@@ -168,7 +185,12 @@ namespace BlackCore
else if (str == "4") return CFacilityType::TWR; else if (str == "4") return CFacilityType::TWR;
else if (str == "5") return CFacilityType::APP; else if (str == "5") return CFacilityType::APP;
else if (str == "6") return CFacilityType::CTR; else if (str == "6") return CFacilityType::CTR;
else return CFacilityType::Unknown;
// we should NOT get here
const QByteArray msg = QStringLiteral("Unknown CFacilityType '%1'").arg(str).toLatin1();
BLACK_AUDIT_X(false, Q_FUNC_INFO, msg.constData());
return CFacilityType::Unknown;
} }
template<> template<>
@@ -189,7 +211,7 @@ namespace BlackCore
case ClientQueryType::Unknown: return "Unknown query type"; case ClientQueryType::Unknown: return "Unknown query type";
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
return {}; return "Unknown query type";
} }
template<> template<>
@@ -205,11 +227,12 @@ namespace BlackCore
else if (str == "INF") return ClientQueryType::INF; else if (str == "INF") return ClientQueryType::INF;
else if (str == "FP") return ClientQueryType::FP; else if (str == "FP") return ClientQueryType::FP;
else if (str == "ACC") return ClientQueryType::AircraftConfig; else if (str == "ACC") return ClientQueryType::AircraftConfig;
else
{ // we should NOT get here
// networkLog(vatSeverityDebug, "ClientQueryType fromString(str)", "Unknown client query type"); const QByteArray msg = QStringLiteral("Unknown ClientQueryType '%1'").arg(str).toLatin1();
return ClientQueryType::Unknown; BLACK_AUDIT_X(false, Q_FUNC_INFO, msg.constData());
} // networkLog(vatSeverityDebug, "ClientQueryType fromString(str)", "Unknown client query type");
return ClientQueryType::Unknown;
} }
template<> template<>
@@ -222,6 +245,7 @@ namespace BlackCore
case FlightType::SVFR: return "S"; case FlightType::SVFR: return "S";
case FlightType::DVFR: return "D"; case FlightType::DVFR: return "D";
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
return {}; return {};
} }
@@ -255,8 +279,9 @@ namespace BlackCore
case CTransponder::StateIdent: case CTransponder::StateIdent:
return QStringLiteral("Y"); return QStringLiteral("Y");
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
return {}; return QStringLiteral("S");
} }
template<> template<>
@@ -269,35 +294,37 @@ namespace BlackCore
} }
template<> template<>
QString toQString(const Capabilities& value) QString toQString(const Capabilities &value)
{ {
switch (value) switch (value)
{ {
case Capabilities::None: return {}; case Capabilities::None: return {};
case Capabilities::AtcInfo: return "ATCINFO"; case Capabilities::AtcInfo: return "ATCINFO";
case Capabilities::SecondaryPos: return "SECPOS"; case Capabilities::SecondaryPos: return "SECPOS";
case Capabilities::AircraftInfo: return "MODELDESC"; case Capabilities::AircraftInfo: return "MODELDESC";
case Capabilities::OngoingCoord: return "ONGOINGCOORD"; case Capabilities::OngoingCoord: return "ONGOINGCOORD";
case Capabilities::InterminPos: return "INTERIMPOS"; case Capabilities::InterminPos: return "INTERIMPOS";
case Capabilities::FastPos: return "FASTPOS"; case Capabilities::FastPos: return "FASTPOS";
case Capabilities::Stealth: return "STEALTH"; case Capabilities::Stealth: return "STEALTH";
case Capabilities::AircraftConfig: return "ACCONFIG"; case Capabilities::AircraftConfig: return "ACCONFIG";
} }
return {}; return {};
} }
template<> template<>
Capabilities fromQString(const QString &str) Capabilities fromQString(const QString &str)
{ {
if (str == "ATCINFO") return Capabilities::AtcInfo; if (str == "ATCINFO") return Capabilities::AtcInfo;
else if (str == "SECPOS") return Capabilities::SecondaryPos; else if (str == "SECPOS") return Capabilities::SecondaryPos;
else if (str == "MODELDESC") return Capabilities::AircraftInfo; else if (str == "MODELDESC") return Capabilities::AircraftInfo;
else if (str == "ONGOINGCOORD") return Capabilities::OngoingCoord; else if (str == "ONGOINGCOORD") return Capabilities::OngoingCoord;
else if (str == "INTERIMPOS") return Capabilities::InterminPos; else if (str == "INTERIMPOS") return Capabilities::InterminPos;
else if (str == "FASTPOS") return Capabilities::FastPos; else if (str == "FASTPOS") return Capabilities::FastPos;
else if (str == "STEALTH") return Capabilities::Stealth; else if (str == "STEALTH") return Capabilities::Stealth;
else if (str == "ACCONFIG") return Capabilities::AircraftConfig; else if (str == "ACCONFIG") return Capabilities::AircraftConfig;
else return Capabilities::None;
return Capabilities::None;
} }
template<> template<>
@@ -307,9 +334,11 @@ namespace BlackCore
else if (str == "Z") return AtisLineType::ZuluLogoff; else if (str == "Z") return AtisLineType::ZuluLogoff;
else if (str == "T") return AtisLineType::TextMessage; else if (str == "T") return AtisLineType::TextMessage;
else if (str == "E") return AtisLineType::LineCount; else if (str == "E") return AtisLineType::LineCount;
else return AtisLineType::Unknown;
return AtisLineType::Unknown;
} }
//! @} //! @}
}
} } // ns
} // ns

View File

@@ -14,7 +14,7 @@ namespace BlackMisc
{ {
QString CFacilityType::convertToQString(bool i18n) const QString CFacilityType::convertToQString(bool i18n) const
{ {
Q_UNUSED(i18n); Q_UNUSED(i18n)
switch (m_facilityType) switch (m_facilityType)
{ {
@@ -29,7 +29,7 @@ namespace BlackMisc
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
return {}; return QStringLiteral("Unknown");
} }
} // namespace } // namespace

View File

@@ -14,11 +14,11 @@ namespace BlackMisc
{ {
QString CLoginMode::convertToQString(bool i18n) const QString CLoginMode::convertToQString(bool i18n) const
{ {
Q_UNUSED(i18n); Q_UNUSED(i18n)
switch (m_loginMode) switch (m_loginMode)
{ {
case Pilot: return QStringLiteral("Pilot"); case Pilot: return QStringLiteral("Pilot");
case Observer: return QStringLiteral("Observer"); case Observer: return QStringLiteral("Observer");
} }