fix code analysis findings
This commit is contained in:
1 parent
e4ea8f46c8
commit
41a9fd20d5
4 files changed
+25
-24
No files matched your search
+21
-20
@@ -36,8 +36,7 @@ using namespace aman;
|
|||||||
static std::string __receivedAmanData;
|
static std::string __receivedAmanData;
|
||||||
|
|
||||||
static std::size_t receiveCurl(void* ptr, std::size_t size, std::size_t nmemb, void* stream) {
|
static std::size_t receiveCurl(void* ptr, std::size_t size, std::size_t nmemb, void* stream) {
|
||||||
(void)stream;
|
std::ignore = stream;
|
||||||
|
|
||||||
std::string serverResult = static_cast<char*>(ptr);
|
std::string serverResult = static_cast<char*>(ptr);
|
||||||
__receivedAmanData += serverResult;
|
__receivedAmanData += serverResult;
|
||||||
return size * nmemb;
|
return size * nmemb;
|
||||||
@@ -69,7 +68,7 @@ PlugIn::PlugIn() :
|
|||||||
/* get the dll-path */
|
/* get the dll-path */
|
||||||
char path[MAX_PATH + 1] = { 0 };
|
char path[MAX_PATH + 1] = { 0 };
|
||||||
const gsl::span<char, MAX_PATH + 1> span(path);
|
const gsl::span<char, MAX_PATH + 1> span(path);
|
||||||
GetModuleFileNameA((HINSTANCE)&__ImageBase, span.data(), span.size());
|
GetModuleFileNameA(gsl::narrow_cast<HINSTANCE>(&__ImageBase), span.data(), span.size());
|
||||||
PathRemoveFileSpecA(span.data());
|
PathRemoveFileSpecA(span.data());
|
||||||
std::string dllPath = span.data();
|
std::string dllPath = span.data();
|
||||||
|
|
||||||
@@ -95,7 +94,7 @@ PlugIn::PlugIn() :
|
|||||||
this->validateBackendData();
|
this->validateBackendData();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlugIn::~PlugIn() noexcept {
|
PlugIn::~PlugIn() {
|
||||||
Backend::instance().deinitialize();
|
Backend::instance().deinitialize();
|
||||||
ZmqContext::instance().deinitialize();
|
ZmqContext::instance().deinitialize();
|
||||||
google::protobuf::ShutdownProtobufLibrary();
|
google::protobuf::ShutdownProtobufLibrary();
|
||||||
@@ -174,7 +173,7 @@ void PlugIn::validateBackendData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* incompatible communication version */
|
/* incompatible communication version */
|
||||||
if (PLUGIN_MAJOR_VERSION != std::atoi(entries[0].c_str()) || PLUGIN_MINOR_VERSION != std::atoi(entries[1].c_str())) {
|
if (PLUGIN_MAJOR_VERSION != std::atoi(gsl::at(entries, 0).c_str()) || PLUGIN_MINOR_VERSION != std::atoi(gsl::at(entries, 1).c_str())) {
|
||||||
MessageBoxA(nullptr, "Plugin version is outdated. An update is required", "AMAN-Error", MB_OK);
|
MessageBoxA(nullptr, "Plugin version is outdated. An update is required", "AMAN-Error", MB_OK);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -200,11 +199,11 @@ EuroScopePlugIn::CRadarScreen* PlugIn::OnRadarScreenCreated(const char* displayN
|
|||||||
return this->m_screen.get();
|
return this->m_screen.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
aman::Aircraft* PlugIn::generateAircraftMessage(EuroScopePlugIn::CRadarTarget& target) {
|
aman::Aircraft* PlugIn::generateAircraftMessage(const EuroScopePlugIn::CRadarTarget& target) const {
|
||||||
if (false == target.IsValid() || false == target.GetCorrelatedFlightPlan().IsValid())
|
if (false == target.IsValid() || false == target.GetCorrelatedFlightPlan().IsValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto flightPlan = target.GetCorrelatedFlightPlan();
|
const auto flightPlan = target.GetCorrelatedFlightPlan();
|
||||||
std::string callsign(target.GetCallsign());
|
std::string callsign(target.GetCallsign());
|
||||||
aman::Aircraft* retval = new aman::Aircraft();
|
aman::Aircraft* retval = new aman::Aircraft();
|
||||||
|
|
||||||
@@ -237,7 +236,7 @@ aman::Aircraft* PlugIn::generateAircraftMessage(EuroScopePlugIn::CRadarTarget& t
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarTarget, aman::AircraftReport* report) {
|
void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarTarget, aman::AircraftReport* report) {
|
||||||
auto flightPlan = radarTarget.GetCorrelatedFlightPlan();
|
const auto flightPlan = radarTarget.GetCorrelatedFlightPlan();
|
||||||
|
|
||||||
/* ignore invalid flightplans */
|
/* ignore invalid flightplans */
|
||||||
if (false == flightPlan.IsValid())
|
if (false == flightPlan.IsValid())
|
||||||
@@ -252,12 +251,12 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* filter invalid destinations */
|
/* filter invalid destinations */
|
||||||
auto destination = std::string_view(flightPlan.GetFlightPlanData().GetDestination());
|
const auto destination = std::string_view(flightPlan.GetFlightPlanData().GetDestination());
|
||||||
if (4 != destination.length())
|
if (4 != destination.length())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* filter by distance to destination */
|
/* filter by distance to destination */
|
||||||
double distanceNM = flightPlan.GetDistanceToDestination();
|
const double distanceNM = flightPlan.GetDistanceToDestination();
|
||||||
if (5.0 > distanceNM || 250.0 < distanceNM)
|
if (5.0 > distanceNM || 250.0 < distanceNM)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -312,7 +311,7 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|||||||
auto split = String::splitString(element.GetName(), " ");
|
auto split = String::splitString(element.GetName(), " ");
|
||||||
|
|
||||||
/* find the correct star */
|
/* find the correct star */
|
||||||
if (0 != split.size() && destination == split[0]) {
|
if (0 != split.size() && destination == gsl::at(split, 0)) {
|
||||||
/* get the IAF */
|
/* get the IAF */
|
||||||
EuroScopePlugIn::CPosition position;
|
EuroScopePlugIn::CPosition position;
|
||||||
if (true == element.GetPosition(&position, 0)) {
|
if (true == element.GetPosition(&position, 0)) {
|
||||||
@@ -333,13 +332,13 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (0 != iafName.length()) {
|
if (0 != iafName.length()) {
|
||||||
auto iafDistance = currentPosition.DistanceTo(iafPosition);
|
const auto iafDistance = currentPosition.DistanceTo(iafPosition);
|
||||||
|
|
||||||
/* calculate the distance to the IAF */
|
/* calculate the distance to the IAF */
|
||||||
double distanceToIaf = 0.0f;
|
double distanceToIaf = 0.0f;
|
||||||
for (int i = 1; i < flightPlan.GetPositionPredictions().GetPointsNumber(); ++i) {
|
for (int i = 1; i < flightPlan.GetPositionPredictions().GetPointsNumber(); ++i) {
|
||||||
double distance = flightPlan.GetPositionPredictions().GetPosition(i).DistanceTo(currentPosition);
|
const double distance = flightPlan.GetPositionPredictions().GetPosition(i).DistanceTo(currentPosition);
|
||||||
double headingDelta = std::abs(radarTarget.GetPosition().GetReportedHeading() - flightPlan.GetPositionPredictions().GetPosition(i).DirectionTo(iafPosition));
|
const double headingDelta = std::abs(radarTarget.GetPosition().GetReportedHeading() - flightPlan.GetPositionPredictions().GetPosition(i).DirectionTo(iafPosition));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1. no direct way to IAF -> some direct given -> stop after lateral passing
|
* 1. no direct way to IAF -> some direct given -> stop after lateral passing
|
||||||
@@ -371,9 +370,10 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|||||||
|
|
||||||
/* set the report time */
|
/* set the report time */
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
auto reportTime = std::chrono::utc_clock::now();
|
const auto reportTime = std::chrono::utc_clock::now();
|
||||||
stream << std::format("{0:%Y%m%d%H%M%S}", reportTime);
|
stream << std::format("{0:%Y%m%d%H%M%S}", reportTime);
|
||||||
report->set_reporttime(String::splitString(stream.str(), ".")[0]);
|
const auto elements = String::splitString(stream.str(), ".");
|
||||||
|
report->set_reporttime(gsl::at(elements, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlugIn::OnCompileCommand(const char* cmdline) {
|
bool PlugIn::OnCompileCommand(const char* cmdline) {
|
||||||
@@ -435,12 +435,13 @@ void PlugIn::OnGetTagItem(EuroScopePlugIn::CFlightPlan flightPlan, EuroScopePlug
|
|||||||
std::transform(destination.begin(), destination.end(), destination.begin(), ::toupper);
|
std::transform(destination.begin(), destination.end(), destination.begin(), ::toupper);
|
||||||
#pragma warning(default: 4244)
|
#pragma warning(default: 4244)
|
||||||
|
|
||||||
bool planExpected, forced;
|
bool planExpected = false, forced = false;
|
||||||
|
const gsl::span<char, 16> tagString(itemString, 16UL);
|
||||||
|
|
||||||
this->m_updateQueueLock.lock();
|
this->m_updateQueueLock.lock();
|
||||||
|
|
||||||
/* check if the inbound is forced */
|
/* check if the inbound is forced */
|
||||||
auto cIt = std::find(this->m_forcedToBackendCallsigns.cbegin(), this->m_forcedToBackendCallsigns.cend(), callsign);
|
const auto cIt = std::find(this->m_forcedToBackendCallsigns.cbegin(), this->m_forcedToBackendCallsigns.cend(), callsign);
|
||||||
forced = this->m_forcedToBackendCallsigns.cend() != cIt;
|
forced = this->m_forcedToBackendCallsigns.cend() != cIt;
|
||||||
|
|
||||||
/* check if the inbound is expected to be planned */
|
/* check if the inbound is expected to be planned */
|
||||||
@@ -475,7 +476,7 @@ void PlugIn::OnGetTagItem(EuroScopePlugIn::CFlightPlan flightPlan, EuroScopePlug
|
|||||||
*colorCode = EuroScopePlugIn::TAG_COLOR_DEFAULT;
|
*colorCode = EuroScopePlugIn::TAG_COLOR_DEFAULT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
itemString[0] = '\0';
|
gsl::at(tagString, 0) = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -490,7 +491,7 @@ void PlugIn::OnFunctionCall(int functionId, const char* itemString, POINT pt, RE
|
|||||||
std::ignore = pt;
|
std::ignore = pt;
|
||||||
std::ignore = area;
|
std::ignore = area;
|
||||||
|
|
||||||
auto radarTarget = this->RadarTargetSelectASEL();
|
const auto radarTarget = this->RadarTargetSelectASEL();
|
||||||
if (false == radarTarget.IsValid() || false == radarTarget.GetCorrelatedFlightPlan().IsValid())
|
if (false == radarTarget.IsValid() || false == radarTarget.GetCorrelatedFlightPlan().IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -45,7 +45,7 @@ namespace aman {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void validateBackendData();
|
void validateBackendData();
|
||||||
aman::Aircraft* generateAircraftMessage(EuroScopePlugIn::CRadarTarget& target);
|
aman::Aircraft* generateAircraftMessage(const EuroScopePlugIn::CRadarTarget& target) const;
|
||||||
void generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarTarget, aman::AircraftReport* report);
|
void generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarTarget, aman::AircraftReport* report);
|
||||||
void addUpdateQueue(EuroScopePlugIn::CRadarTarget& radarTarget);
|
void addUpdateQueue(EuroScopePlugIn::CRadarTarget& radarTarget);
|
||||||
void updateInbound(EuroScopePlugIn::CRadarTarget& radarTarget);
|
void updateInbound(EuroScopePlugIn::CRadarTarget& radarTarget);
|
||||||
@@ -71,7 +71,7 @@ namespace aman {
|
|||||||
/**
|
/**
|
||||||
* @brief Destroys all internal strcutures
|
* @brief Destroys all internal strcutures
|
||||||
*/
|
*/
|
||||||
~PlugIn() noexcept;
|
~PlugIn();
|
||||||
|
|
||||||
PlugIn(const PlugIn&) = delete;
|
PlugIn(const PlugIn&) = delete;
|
||||||
PlugIn(PlugIn&&) = delete;
|
PlugIn(PlugIn&&) = delete;
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
using namespace aman;
|
using namespace aman;
|
||||||
|
|
||||||
RadarScreen::RadarScreen() :
|
RadarScreen::RadarScreen() noexcept :
|
||||||
EuroScopePlugIn::CRadarScreen() { }
|
EuroScopePlugIn::CRadarScreen() { }
|
||||||
|
|
||||||
RadarScreen::~RadarScreen() { }
|
RadarScreen::~RadarScreen() { }
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ namespace aman {
|
|||||||
/**
|
/**
|
||||||
* @brief Creates a new RADAR screen
|
* @brief Creates a new RADAR screen
|
||||||
*/
|
*/
|
||||||
RadarScreen();
|
RadarScreen() noexcept;
|
||||||
/**
|
/**
|
||||||
* @brief Destroys the internal structure
|
* @brief Destroys the internal structure
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in new issue
Block a user