Skip to content

Commit 1ecbe09

Browse files
Merge pull request #1874 from ithier/iox-1394-fix-axivion-warnings-in-buffer-and-container-modules
Fix warnings in buffer and container modules
2 parents 3a782ad + 8152d35 commit 1ecbe09

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

iceoryx_hoofs/include/iceoryx_hoofs/cxx/vector.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2-
// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved.
2+
// Copyright (c) 2021 - 2023 by Apex.AI Inc. All rights reserved.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -220,6 +220,8 @@ class vector final
220220

221221
void clearFrom(const uint64_t startPosition) noexcept;
222222

223+
// AXIVION Next Construct AutosarC++19_03-A1.1.1 : Object size limit is not relevant for
224+
// containers stored in shared memory.
223225
UninitializedArray<T, Capacity> m_data{};
224226
uint64_t m_size{0U};
225227
};

iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/stack.inl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved.
1+
// Copyright (c) 2021 - 2023 by Apex.AI Inc. All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -162,6 +162,8 @@ inline bool stack<T, Capacity>::push(Targs&&... args) noexcept
162162
}
163163

164164
// AXIVION Next Line AutosarC++19_03-A18.5.10 : every entry of m_data is aligned to alignof(T)
165+
// AXIVION Next Line FaultDetection-IndirectAssignmentOverflow : False positive. Size at
166+
// location guaranteed by T.
165167
new (&m_data[m_size++]) T(std::forward<Targs>(args)...);
166168
return true;
167169
}

iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/vector.inl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2-
// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved.
2+
// Copyright (c) 2021 - 2023 by Apex.AI Inc. All rights reserved.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -53,6 +53,8 @@ inline vector<T, Capacity>::vector(const uint64_t count) noexcept
5353
for (uint64_t i{0U}; i < m_size; ++i)
5454
{
5555
// AXIVION Next Line AutosarC++19_03-A18.5.2 : false positive, it is a placement new
56+
// AXIVION Next Line FaultDetection-IndirectAssignmentOverflow : False positive. Size at
57+
// location guaranteed by T.
5658
new (&at(i)) T();
5759
}
5860
}
@@ -87,6 +89,8 @@ inline vector<T, Capacity>& vector<T, Capacity>::operator=(const vector& rhs) no
8789
// copy using copy assignment
8890
for (; i < minSize; ++i)
8991
{
92+
// AXIVION Next Line AutosarC++19_03-A5.0.1 : Expands to basic variable assignment.
93+
// Evaluation order is inconsequential.
9094
at(i) = rhs.at(i);
9195
}
9296

@@ -116,6 +120,8 @@ inline vector<T, Capacity>& vector<T, Capacity>::operator=(vector&& rhs) noexcep
116120
// move using move assignment
117121
for (; i < minSize; ++i)
118122
{
123+
// AXIVION Next Line AutosarC++19_03-A5.0.1 : Expands to basic variable assignment.
124+
// Evaluation order is inconsequential.
119125
at(i) = std::move(rhs.at(i));
120126
}
121127

@@ -164,6 +170,9 @@ inline bool vector<T, Capacity>::emplace_back(Targs&&... args) noexcept
164170
{
165171
if (m_size < Capacity)
166172
{
173+
// AXIVION Next Construct FaultDetection-IndirectAssignmentOverflow : False positive. Size at
174+
// location guaranteed by T
175+
// AXIVION Next Construct AutosarC++19_03-A5.0.1 : Evaluation order is inconsequential.
167176
new (&at(m_size++)) T(std::forward<Targs>(args)...);
168177
return true;
169178
}
@@ -174,7 +183,7 @@ template <typename T, uint64_t Capacity>
174183
template <typename... Targs>
175184
inline bool vector<T, Capacity>::emplace(const uint64_t position, Targs&&... args) noexcept
176185
{
177-
const auto sizeBeforeEmplace = m_size;
186+
const uint64_t sizeBeforeEmplace = m_size;
178187
if ((m_size >= Capacity) || ((position >= Capacity) || (position > sizeBeforeEmplace)))
179188
{
180189
return false;
@@ -350,10 +359,13 @@ inline bool vector<T, Capacity>::erase(iterator position) noexcept
350359
{
351360
if ((begin() <= position) && (position < end()))
352361
{
362+
// AXIVION Next Line AutosarC++19_03-M5.0.9 : False positive. Pointer arithmetic occurs here.
353363
uint64_t index{static_cast<uint64_t>(position - begin())};
354364
size_t n{index};
355365
while ((n + 1U) < size())
356366
{
367+
// AXIVION Next Line AutosarC++19_03-A5.0.1 : Expands to basic variable assignment.
368+
// Evaluation order is inconsequential.
357369
at(n) = std::move(at(n + 1U));
358370
++n;
359371
}

0 commit comments

Comments
 (0)