Skip to content

Commit

Permalink
Fix or ignore sign conversion warnings which affect macOS builds with…
Browse files Browse the repository at this point in the history
… Clang

See #263 (comment).

Signed-off-by: Johannes Meyer <[email protected]>
  • Loading branch information
meyerj committed Jul 23, 2020
1 parent 9a5c2d2 commit 0d8f39d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ find_package(ament_cmake_ros REQUIRED)
ament_python_install_package(${PROJECT_NAME})

if(NOT WIN32)
add_compile_options(-Wall -Wextra -Wpedantic -Wconversion)
# About -Wno-sign-conversion: With Clang, -Wconversion implies -Wsign-conversion. There are a number of
# implicit sign conversions in gtest.cc, see https://ci.ros2.org/job/ci_osx/9381/clang/.
# Hence disabling -Wsign-conversion for now until all those have eventually been fixed.
# (from https://github.com/ros2/rcutils/pull/263#issuecomment-663252537)
add_compile_options(-Wall -Wextra -Wconversion -Wno-sign-conversion -Wpedantic)
endif()

if(WIN32)
Expand Down
7 changes: 4 additions & 3 deletions test/test_char_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ TEST_F(ArrayCharTest, resize) {
rcutils_ret_t ret = rcutils_char_array_init(&char_array, 5, &allocator);
ASSERT_EQ(RCUTILS_RET_OK, ret);

char_array.buffer_length = snprintf(char_array.buffer, char_array.buffer_capacity, "1234") + 1;
char_array.buffer_length =
static_cast<std::size_t>(snprintf(char_array.buffer, char_array.buffer_capacity, "1234") + 1);
EXPECT_STREQ("1234", char_array.buffer);

ret = rcutils_char_array_resize(&char_array, 0);
Expand All @@ -86,8 +87,8 @@ TEST_F(ArrayCharTest, resize) {
EXPECT_EQ(11lu, char_array.buffer_capacity);
EXPECT_EQ(5lu, char_array.buffer_length);

char_array.buffer_length = snprintf(
char_array.buffer, char_array.buffer_capacity, "0987654321") + 1;
char_array.buffer_length =
static_cast<std::size_t>(snprintf(char_array.buffer, char_array.buffer_capacity, "0987654321") + 1);
EXPECT_STREQ("0987654321", char_array.buffer);

ret = rcutils_char_array_resize(&char_array, 3);
Expand Down
2 changes: 1 addition & 1 deletion test/test_logging_macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ TEST_F(TestLoggingMacros, test_logging_function) {
}

TEST_F(TestLoggingMacros, test_logging_skipfirst) {
for (uint32_t i : {1, 2, 3, 4, 5}) {
for (uint32_t i : {1u, 2u, 3u, 4u, 5u}) {
RCUTILS_LOG_WARN_SKIPFIRST("message %u", i);
EXPECT_EQ(i - 1, g_log_calls);
}
Expand Down

0 comments on commit 0d8f39d

Please sign in to comment.