From b29fd03fe4e75f92296f2214616b62f6cbec56cb Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Wed, 6 Jul 2022 15:43:01 +0200 Subject: [PATCH] iox-#1196 Fix gcc warnings Signed-off-by: Christian Eltzschig --- .../iceoryx_hoofs/internal/graphs/directed_graph.hpp | 6 +++--- .../test_resizeable_lockfree_queue_stresstest.cpp | 8 ++++---- iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp | 4 ++++ .../test/moduletests/test_concurrent_trigger_queue.cpp | 4 ++++ .../test/moduletests/test_cxx_deadline_timer.cpp | 4 ++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/graphs/directed_graph.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/internal/graphs/directed_graph.hpp index 5a525c76af..c067e1efde 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/graphs/directed_graph.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/graphs/directed_graph.hpp @@ -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(numberOfVertices())) + if (index != INVALID_INDEX && index < static_cast(numberOfVertices())) { return &m_vertices[index].successors; } @@ -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(numberOfVertices())) + if (index != INVALID_INDEX && index < static_cast(numberOfVertices())) { return &m_vertices[index].predecessors; } @@ -259,7 +259,7 @@ class DirectedGraph bool isValid(Index_t index) { - return index >= 0 && index < static_cast(m_vertices.size()); + return index != INVALID_INDEX && index < static_cast(m_vertices.size()); } }; diff --git a/iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp b/iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp index 72c5b3006d..cfb6625fed 100644 --- a/iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp +++ b/iceoryx_hoofs/test/integrationtests/test_resizeable_lockfree_queue_stresstest.cpp @@ -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(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, @@ -292,9 +292,9 @@ void changeCapacity(Queue& queue, k = 1; incrementK = true; } - else if (k >= n) + else if (static_cast(k) >= n) { - k = n - 1; + k = static_cast(n - 1); incrementK = false; } diff --git a/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp b/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp index ea28ae6f2a..09922b1a29 100644 --- a/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp +++ b/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp @@ -29,10 +29,14 @@ using namespace ::testing; constexpr uint32_t Size{4}; using LoFFLiTestSubjects = Types; +#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 class LoFFLi_test : public Test diff --git a/iceoryx_hoofs/test/moduletests/test_concurrent_trigger_queue.cpp b/iceoryx_hoofs/test/moduletests/test_concurrent_trigger_queue.cpp index ab9c7de37a..50a7370ab6 100644 --- a/iceoryx_hoofs/test/moduletests/test_concurrent_trigger_queue.cpp +++ b/iceoryx_hoofs/test/moduletests/test_concurrent_trigger_queue.cpp @@ -67,10 +67,14 @@ using TriggerQueueTestSubjects = Types, TriggerQueue, TriggerQueue>; +#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) diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_deadline_timer.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_deadline_timer.cpp index 5d172602c2..c62b1b8f1c 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_deadline_timer.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_deadline_timer.cpp @@ -48,11 +48,11 @@ class DeadlineTimer_test : public Test std::atomic 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");