Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1196 Fix gcc warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Eltzschig <[email protected]>
  • Loading branch information
elfenpiff committed Jul 6, 2022
1 parent 068e8f7 commit b29fd03
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class DirectedGraph
/// @return pointer to the list of successors, nullptr if index does not exist in the graph
const AdjacencyList* getSuccessors(Index_t index)
{
if (index >= 0 && index < static_cast<Index_t>(numberOfVertices()))
if (index != INVALID_INDEX && index < static_cast<Index_t>(numberOfVertices()))
{
return &m_vertices[index].successors;
}
Expand All @@ -132,7 +132,7 @@ class DirectedGraph
/// @return pointer to the list of predecessors, nullptr if index does not exist in the graph
const AdjacencyList* getPredecessors(Index_t index)
{
if (index >= 0 && index < static_cast<Index_t>(numberOfVertices()))
if (index != INVALID_INDEX && index < static_cast<Index_t>(numberOfVertices()))
{
return &m_vertices[index].predecessors;
}
Expand Down Expand Up @@ -259,7 +259,7 @@ class DirectedGraph

bool isValid(Index_t index)
{
return index >= 0 && index < static_cast<Index_t>(m_vertices.size());
return index != INVALID_INDEX && index < static_cast<Index_t>(m_vertices.size());
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ void changeCapacity(Queue& queue,
g_barrier.notify();

const uint64_t n = capacities.size(); // number of different capacities
uint64_t k = n; // index of current capacity to be used
bool incrementK = false; // increment delta of the index k, will be 1 or -1
int64_t k = static_cast<int64_t>(n); // index of current capacity to be used
bool incrementK = false; // states if k is incremented or decremented by 1
numChanges = 0; // number of capacity changes performed

// capacities will contain a number of pre generated capacities to switch between,
Expand Down Expand Up @@ -292,9 +292,9 @@ void changeCapacity(Queue& queue,
k = 1;
incrementK = true;
}
else if (k >= n)
else if (static_cast<uint64_t>(k) >= n)
{
k = n - 1;
k = static_cast<int64_t>(n - 1);
incrementK = false;
}

Expand Down
4 changes: 4 additions & 0 deletions iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ using namespace ::testing;
constexpr uint32_t Size{4};
using LoFFLiTestSubjects = Types<iox::concurrent::LoFFLi>;

#ifdef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#endif
TYPED_TEST_SUITE(LoFFLi_test, LoFFLiTestSubjects);
#ifdef __clang__
#pragma GCC diagnostic pop
#endif

template <typename LoFFLiType>
class LoFFLi_test : public Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ using TriggerQueueTestSubjects = Types<TriggerQueue<uint64_t, 1, FiFo>,
TriggerQueue<uint64_t, 10, ResizeableLockFreeQueue>,
TriggerQueue<uint64_t, 100, ResizeableLockFreeQueue>>;

#ifdef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#endif
TYPED_TEST_SUITE(TriggerQueue_test, TriggerQueueTestSubjects);
#ifdef __clang__
#pragma GCC diagnostic pop
#endif


TYPED_TEST(TriggerQueue_test, EmptyOnConstruction)
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_hoofs/test/moduletests/test_cxx_deadline_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class DeadlineTimer_test : public Test

std::atomic<int> numberOfCalls{0};
static const Duration TIMEOUT;
static const int SLEEPTIME;
static const uint64_t SLEEPTIME;
};

const Duration DeadlineTimer_test::TIMEOUT{10_ms};
const int DeadlineTimer_test::SLEEPTIME = DeadlineTimer_test::TIMEOUT.toMilliseconds();
const uint64_t DeadlineTimer_test::SLEEPTIME = DeadlineTimer_test::TIMEOUT.toMilliseconds();

TIMING_TEST_F(DeadlineTimer_test, ZeroTimeoutTest, Repeat(5), [&] {
::testing::Test::RecordProperty("TEST_ID", "eb956212-5565-45d6-8f2a-64f79a0709f0");
Expand Down

0 comments on commit b29fd03

Please sign in to comment.