Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iox-#1196 fix compiler warnings in hoofs tests #1453

Conversation

elfenpiff
Copy link
Contributor

@elfenpiff elfenpiff commented Jul 6, 2022

Pre-Review Checklist for the PR Author

  1. Code follows the coding style of CONTRIBUTING.md
  2. Tests follow the best practice for testing
  3. Changelog updated in the unreleased section including API breaking changes
  4. Branch follows the naming format (iox-#123-this-is-a-branch)
  5. Commits messages are according to this guideline
    • Commit messages have the issue ID (iox-#123 commit text)
    • Commit messages are signed (git commit -s)
    • Commit author matches Eclipse Contributor Agreement (and ECA is signed)
  6. Update the PR title
    • Follow the same conventions as for commit messages
    • Link to the relevant issue
  7. Relevant issues are linked
  8. Add sensible notes for the reviewer
  9. All checks have passed (except task-list-completed)
  10. Assign PR to reviewer

Notes for Reviewer

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Code according to our coding style and naming conventions
  • Unit tests have been written for new behavior
    • Each unit test case has a unique UUID
  • Public API changes are documented via doxygen
  • Copyright owner are updated in the changed files
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

@elfenpiff elfenpiff self-assigned this Jul 6, 2022
@elfenpiff elfenpiff changed the title Iox #1196 fix compiler warnings in hoofs tests iox-#1196 fix compiler warnings in hoofs tests Jul 6, 2022
Copy link
Contributor

@mossmaurice mossmaurice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left a few nitpicks.

iceoryx_hoofs/test/moduletests/test_cxx_forward_list.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_cxx_forward_list.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_cxx_function_ref.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_cxx_list.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_cxx_list.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_cxx_stack.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_objectpool.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_relative_pointer.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_unit_duration.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_unit_duration.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@MatthiasKillat MatthiasKillat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most comments refer to issues with introducing unnecessary casts (as far as I can see) when it instead would be better to change the signedness of some iteration variable or similar.

I think the goal should be to avoid these kinds of casts as they are usually a (interface) design problem.

using AdjacencyList = iox::cxx::vector<VertexType*, DEGREE_LIMIT>;

static constexpr Index_t INVALID_INDEX = -1;
static constexpr Index_t INVALID_INDEX = std::numeric_limits<uint64_t>::max();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has logical implications if set to this maximum and should not be changed like this (as any positive integer is a valid value). I think it is better to keep the value signed. Furthermore we will never have more nodes than we can store with 32 bits (we would be out of memory first) and hence not use a 64 bit integer.

When suddenly the invalid value is positive I cannot guarantee it breaks something at the limits (which are not tested, as is the case for many classes...).

I know the graph is not used (leftover from some internals in the past) and if we will ever reuse something like this I will refactor it for more generality and performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will reduce the size to 32 but would stick with unsigned since this type is used in array operator[] and this requires an unsigned integer. So I have to write a little less static_cast

@@ -35,14 +35,14 @@ namespace
{
struct Data
{
Data(int id = 0, size_t count = 0)
Data(uint64_t id = 0U, uint64_t count = 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be done of course but I thought in test code int is ok? Same with size_t, esecially if we interact with the STL (not the case here).

We have to be careful with upgrading everything to uint64_t without considering context as this may cause other issues. Here it is ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But with int and size_t we get warnings when we compare or assign it to uint64_t types which are returned by capacity, size or other functions.

iceoryx_hoofs/test/moduletests/test_cxx_algorithm.cpp Outdated Show resolved Hide resolved
@@ -313,26 +313,26 @@ TEST_F(forward_list_test, NotFullWhenFilledWithCapacityAndEraseOneElements)
TEST_F(forward_list_test, NotFullWhenFilledWithCapacityAndEraseOneAndReinsertElements)
{
::testing::Test::RecordProperty("TEST_ID", "7df1e41e-f3c2-4ea2-9ed1-ed68a5342ce2");
uint64_t i = 0U;
for (; i < sut.capacity(); ++i)
int64_t counter = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this counter could be uint64_t and we would avoid all cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually int64_t is better since sut requires signed integers and changing the sut to unsigned is even more work

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, less changes that way. In theory the tests can be redesigned but it is not worth it.

iceoryx_hoofs/test/moduletests/test_cxx_forward_list.cpp Outdated Show resolved Hide resolved
@@ -294,20 +294,20 @@ TEST_F(list_test, NotFullWhenFilledWithCapacityAndEraseOneElements)
TEST_F(list_test, NotFullWhenFilledWithCapacityAndEraseOneAndReinsertElements)
{
::testing::Test::RecordProperty("TEST_ID", "c7e70ac7-e476-43aa-976c-1ac78513c869");
uint64_t i = 0U;
for (; i < sut.capacity(); ++i)
int64_t counter = 0U;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think counter should be unsigned to avoid the casts.

Has multiple occurrences in the following tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same again, the list requires signed integers and switching to unsigned requires even more work.

iceoryx_hoofs/test/moduletests/test_cxx_stack.cpp Outdated Show resolved Hide resolved
elfenpiff added 2 commits July 6, 2022 14:52
…make STACK_SIZE in test uint64_t again

Signed-off-by: Christian Eltzschig <[email protected]>
mossmaurice
mossmaurice previously approved these changes Jul 6, 2022
@mossmaurice
Copy link
Contributor

@elfenpiff Ubuntu is still failing:

[ 27%] Building CXX object posh/CMakeFiles/iceoryx_posh_roudi.dir/source/roudi/memory/memory_block.cpp.o
/home/runner/work/iceoryx/iceoryx/iceoryx_hoofs/test/moduletests/test_concurrent_loffli.cpp:33:32: error: unknown option after ‘#pragma GCC diagnostic’ kind [-Werror=pragmas]
   33 | #pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
      |  

Copy link
Contributor

@MatthiasKillat MatthiasKillat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a comment out of sync but should be fixed.

@@ -313,26 +313,26 @@ TEST_F(forward_list_test, NotFullWhenFilledWithCapacityAndEraseOneElements)
TEST_F(forward_list_test, NotFullWhenFilledWithCapacityAndEraseOneAndReinsertElements)
{
::testing::Test::RecordProperty("TEST_ID", "7df1e41e-f3c2-4ea2-9ed1-ed68a5342ce2");
uint64_t i = 0U;
for (; i < sut.capacity(); ++i)
int64_t counter = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, less changes that way. In theory the tests can be redesigned but it is not worth it.

Signed-off-by: Christian Eltzschig <[email protected]>
@elfenpiff elfenpiff force-pushed the iox-#1196-fix-compiler-warnings-in-hoofs-tests branch from ac9efd2 to b29fd03 Compare July 6, 2022 13:46
mossmaurice
mossmaurice previously approved these changes Jul 6, 2022
@elfenpiff elfenpiff force-pushed the iox-#1196-fix-compiler-warnings-in-hoofs-tests branch from 399bc62 to 2802cf8 Compare July 6, 2022 14:55
@elfenpiff elfenpiff force-pushed the iox-#1196-fix-compiler-warnings-in-hoofs-tests branch from 2802cf8 to 07359d8 Compare July 6, 2022 15:24
@elfenpiff elfenpiff force-pushed the iox-#1196-fix-compiler-warnings-in-hoofs-tests branch from d41eb82 to 971d88e Compare July 6, 2022 16:12
@elfenpiff elfenpiff force-pushed the iox-#1196-fix-compiler-warnings-in-hoofs-tests branch from 971d88e to 6dd45cc Compare July 6, 2022 16:33
@codecov
Copy link

codecov bot commented Jul 6, 2022

Codecov Report

Merging #1453 (6dd45cc) into master (1e1ac61) will increase coverage by 0.02%.
The diff coverage is 40.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1453      +/-   ##
==========================================
+ Coverage   78.75%   78.78%   +0.02%     
==========================================
  Files         377      377              
  Lines       14490    14490              
  Branches     2011     2011              
==========================================
+ Hits        11412    11416       +4     
+ Misses       2438     2437       -1     
+ Partials      640      637       -3     
Flag Coverage Δ
unittests 78.44% <40.00%> (+0.02%) ⬆️
unittests_timing 14.87% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...e/iceoryx_hoofs/internal/graphs/directed_graph.hpp 92.20% <25.00%> (+1.29%) ⬆️
...oofs/include/iceoryx_hoofs/internal/cxx/string.inl 98.49% <100.00%> (ø)
iceoryx_posh/source/roudi/port_manager.cpp 84.42% <0.00%> (+0.18%) ⬆️
...x_hoofs/internal/graphs/directed_acyclic_graph.hpp 87.17% <0.00%> (+2.56%) ⬆️
iceoryx_hoofs/source/concurrent/loffli.cpp 88.57% <0.00%> (+2.85%) ⬆️

@elfenpiff elfenpiff merged commit 114afea into eclipse-iceoryx:master Jul 6, 2022
@elfenpiff elfenpiff deleted the iox-#1196-fix-compiler-warnings-in-hoofs-tests branch July 6, 2022 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants