Skip to content

Commit

Permalink
Merge pull request eclipse-iceoryx#1882 from ithier/iox-1394-fix-axiv…
Browse files Browse the repository at this point in the history
…ion-warnings-in-buffer-and-container-modules-2

Fix more warnings in vector.inl & stack.inl
  • Loading branch information
elBoberido authored Feb 8, 2023
2 parents e043656 + 5fe8b4e commit 18e7b34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
5 changes: 2 additions & 3 deletions iceoryx_hoofs/buffer/include/iox/detail/stack.inl
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ inline bool stack<T, Capacity>::push(Targs&&... args) noexcept
return false;
}

// AXIVION Next Line AutosarC++19_03-A18.5.10 : every entry of m_data is aligned to alignof(T)
// AXIVION Next Line FaultDetection-IndirectAssignmentOverflow : False positive. Size at
// location guaranteed by T.
// AXIVION Next Construct AutosarC++19_03-A18.5.10 : every entry of m_data is aligned to alignof(T)
// AXIVION Next Construct FaultDetection-IndirectAssignmentOverflow : Size guaranteed by T.
new (&m_data[m_size++]) T(std::forward<Targs>(args)...);
return true;
}
Expand Down
21 changes: 7 additions & 14 deletions iceoryx_hoofs/container/include/iox/detail/vector.inl
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ inline vector<T, Capacity>::vector(const uint64_t count) noexcept
m_size = std::min(count, Capacity);
for (uint64_t i{0U}; i < m_size; ++i)
{
// AXIVION Next Line AutosarC++19_03-A18.5.2 : false positive, it is a placement new
// AXIVION Next Line FaultDetection-IndirectAssignmentOverflow : False positive. Size at
// location guaranteed by T.
// AXIVION Next Line AutosarC++19_03-A18.5.2, FaultDetection-IndirectAssignmentOverflow : False positive, it is a placement new. Size guaranteed by T.
new (&at(i)) T();
}
}
Expand Down Expand Up @@ -87,8 +85,7 @@ inline vector<T, Capacity>& vector<T, Capacity>::operator=(const vector& rhs) no
// copy using copy assignment
for (; i < minSize; ++i)
{
// AXIVION Next Line AutosarC++19_03-A5.0.1 : Expands to basic variable assignment.
// Evaluation order is inconsequential.
// AXIVION Next Line AutosarC++19_03-A5.0.1 : Expands to basic variable assignment. Evaluation order is inconsequential.
at(i) = rhs.at(i);
}

Expand Down Expand Up @@ -118,8 +115,7 @@ inline vector<T, Capacity>& vector<T, Capacity>::operator=(vector&& rhs) noexcep
// move using move assignment
for (; i < minSize; ++i)
{
// AXIVION Next Line AutosarC++19_03-A5.0.1 : Expands to basic variable assignment.
// Evaluation order is inconsequential.
// AXIVION Next Line AutosarC++19_03-A5.0.1 : Expands to basic variable assignment. Evaluation order is inconsequential.
at(i) = std::move(rhs.at(i));
}

Expand Down Expand Up @@ -168,9 +164,7 @@ inline bool vector<T, Capacity>::emplace_back(Targs&&... args) noexcept
{
if (m_size < Capacity)
{
// AXIVION Next Construct FaultDetection-IndirectAssignmentOverflow : False positive. Size at
// location guaranteed by T
// AXIVION Next Construct AutosarC++19_03-A5.0.1 : Evaluation order is inconsequential.
// AXIVION Next Line AutosarC++19_03-A5.0.1, FaultDetection-IndirectAssignmentOverflow: Size guaranteed by T. Evaluation order is inconsequential.
new (&at(m_size++)) T(std::forward<Targs>(args)...);
return true;
}
Expand All @@ -181,7 +175,7 @@ template <typename T, uint64_t Capacity>
template <typename... Targs>
inline bool vector<T, Capacity>::emplace(const uint64_t position, Targs&&... args) noexcept
{
const uint64_t sizeBeforeEmplace = m_size;
const uint64_t sizeBeforeEmplace{m_size};
if ((m_size >= Capacity) || ((position >= Capacity) || (position > sizeBeforeEmplace)))
{
return false;
Expand Down Expand Up @@ -347,7 +341,7 @@ inline typename vector<T, Capacity>::iterator vector<T, Capacity>::end() noexcep
template <typename T, uint64_t Capacity>
inline typename vector<T, Capacity>::const_iterator vector<T, Capacity>::end() const noexcept
{
// AXIVION Next Construct AutosarC++19_03-A5.2.4 : Type-safety ensured by template parameter
// AXIVION Next Construct AutosarC++19_03-A5.2.4, AutosarC++19_03-A5.0.4, AutosarC++19_03-M5.0.15 : Type-safety ensured by template parameter.
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
return reinterpret_cast<const_iterator>(&(at_unchecked(0)) + m_size);
}
Expand All @@ -362,8 +356,7 @@ inline bool vector<T, Capacity>::erase(iterator position) noexcept
size_t n{index};
while ((n + 1U) < size())
{
// AXIVION Next Line AutosarC++19_03-A5.0.1 : Expands to basic variable assignment.
// Evaluation order is inconsequential.
// AXIVION Next Line AutosarC++19_03-A5.0.1 : Expands to basic variable assignment. Evaluation order is inconsequential.
at(n) = std::move(at(n + 1U));
++n;
}
Expand Down

0 comments on commit 18e7b34

Please sign in to comment.