Skip to content

Commit

Permalink
cppCheckk on SDK
Browse files Browse the repository at this point in the history
**Description:** It looks like it been a long time since cppCheck was run on SDK. Many issues are now flagged.  I only fixed a few of them.

**Testing Performed:** Compile
  • Loading branch information
George Ruhlmann committed Sep 14, 2022
1 parent 8f81537 commit eeda1ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion SDK/simCore/Calc/Calculations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ double calculateGroundDist(const Vec3 &fromLla, const Vec3 &toLla, const EarthMo
Coordinate fromPos;
Coordinate toPos;

if (model == FLAT_EARTH && coordConv && coordConv->hasReferenceOrigin())
if (model == FLAT_EARTH && coordConv->hasReferenceOrigin())
{
coordConv->convert(Coordinate(COORD_SYS_LLA, fromLla), fromPos, COORD_SYS_ENU);
coordConv->convert(Coordinate(COORD_SYS_LLA, toLla), toPos, COORD_SYS_ENU);
Expand Down
9 changes: 5 additions & 4 deletions SDK/simCore/Time/TimeClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,19 @@ Seconds TimeStamp::operator - (const TimeStamp& t) const
return ZERO_SECONDS;
}

int year = 0;
Seconds secondsValue;

if (yearDifference > 0)
{
secondsValue = Seconds(SECPERDAY * daysPerYear(t.referenceYear_), 0) - t.secondsSinceRefYear_;
for (year = t.referenceYear_ + 1; year < referenceYear_; ++year)
for (auto year = t.referenceYear_ + 1; year < referenceYear_; ++year)
secondsValue += Seconds(SECPERDAY * daysPerYear(year), 0);
secondsValue += secondsSinceRefYear_;
}
else if (yearDifference < 0)
{
secondsValue = (Seconds(-1, 0) * t.secondsSinceRefYear_);
for (year = t.referenceYear_ - 1; year > referenceYear_; --year)
for (auto year = t.referenceYear_ - 1; year > referenceYear_; --year)
secondsValue -= Seconds(SECPERDAY * daysPerYear(year), 0);
secondsValue -= (Seconds(SECPERDAY * daysPerYear(referenceYear_), 0) - secondsSinceRefYear_);
}
Expand Down Expand Up @@ -506,7 +505,7 @@ class InvalidParameterDetection
{
_set_invalid_parameter_handler(oldHandler_);
}

private:
static void invalidParameter_(const wchar_t* expression, const wchar_t* function,
const wchar_t* file, unsigned int line, uintptr_t pReserved)
Expand All @@ -524,7 +523,9 @@ std::string TimeStamp::strftime(const std::string& format) const
if (simCore::INFINITE_TIME_STAMP == *this)
return "";

// Do not remove; cppCheck flags as unused but the constructor and destructor do actual work.
InvalidParameterDetection detectInvalid;

const auto& timeStruct = simCore::getTimeStruct(*this);

// Try/catch since MSVC version will throw an exception on error
Expand Down

0 comments on commit eeda1ab

Please sign in to comment.