Merge pull request #16 from ros2/fix_warnings

Fix warnings
This commit is contained in:
William Woodall 2016-01-05 16:00:37 -08:00
commit 0fd8b01564
6 changed files with 50 additions and 47 deletions

View file

@ -63,17 +63,19 @@ __wait_set_is_valid(const rcl_wait_set_t * wait_set)
static void
__wait_set_clean_up(rcl_wait_set_t * wait_set, rcl_allocator_t allocator)
{
rcl_ret_t ret;
if (wait_set->subscriptions) {
ret = rcl_wait_set_resize_subscriptions(wait_set, 0);
rcl_ret_t ret = rcl_wait_set_resize_subscriptions(wait_set, 0);
(void)ret; // NO LINT
assert(ret == RCL_RET_OK); // Defensive, shouldn't fail with size 0.
}
if (wait_set->guard_conditions) {
ret = rcl_wait_set_resize_guard_conditions(wait_set, 0);
rcl_ret_t ret = rcl_wait_set_resize_guard_conditions(wait_set, 0);
(void)ret; // NO LINT
assert(ret == RCL_RET_OK); // Defensive, shouldn't fail with size 0.
}
if (wait_set->timers) {
ret = rcl_wait_set_resize_timers(wait_set, 0);
rcl_ret_t ret = rcl_wait_set_resize_timers(wait_set, 0);
(void)ret; // NO LINT
assert(ret == RCL_RET_OK); // Defensive, shouldn't fail with size 0.
}
if (wait_set->impl) {
@ -429,6 +431,7 @@ rcl_wait(rcl_wait_set_t * wait_set, int64_t timeout)
if (ret == RMW_RET_TIMEOUT) {
// Assume none were set (because timeout was reached first), and clear all.
rcl_ret_t rcl_ret;
(void)rcl_ret; // NO LINT
rcl_ret = rcl_wait_set_clear_subscriptions(wait_set);
assert(rcl_ret == RCL_RET_OK); // Defensive, shouldn't fail with valid wait_set.
rcl_ret = rcl_wait_set_clear_guard_conditions(wait_set);

View file

@ -72,13 +72,13 @@ TEST_F(TestAllocatorFixture, test_default_allocator_normal) {
assert_no_realloc_begin();
assert_no_free_begin();
void * allocated_memory = allocator.allocate(1024, allocator.state);
EXPECT_EQ(mallocs, 1);
EXPECT_EQ(mallocs, 1u);
EXPECT_NE(allocated_memory, nullptr);
allocated_memory = allocator.reallocate(allocated_memory, 2048, allocator.state);
EXPECT_EQ(reallocs, 1);
EXPECT_EQ(reallocs, 1u);
EXPECT_NE(allocated_memory, nullptr);
allocator.deallocate(allocated_memory, allocator.state);
EXPECT_EQ(mallocs, 1);
EXPECT_EQ(reallocs, 1);
EXPECT_EQ(frees, 1);
EXPECT_EQ(mallocs, 1u);
EXPECT_EQ(reallocs, 1u);
EXPECT_EQ(frees, 1u);
}

View file

@ -201,7 +201,7 @@ TEST_F(TestNodeFixture, test_rcl_node_accessors) {
EXPECT_EQ(RCL_RET_OK, ret);
if (RCL_RET_OK == ret && (!is_windows || !is_opensplice)) {
// Can only expect the domain id to be 42 if not windows or not opensplice.
EXPECT_EQ(42, actual_domain_id);
EXPECT_EQ(42u, actual_domain_id);
}
// Test rcl_node_get_rmw_handle().
rmw_node_t * node_handle;
@ -227,14 +227,14 @@ TEST_F(TestNodeFixture, test_rcl_node_accessors) {
// Test rcl_node_get_rcl_instance_id().
uint64_t instance_id;
instance_id = rcl_node_get_rcl_instance_id(nullptr);
EXPECT_EQ(0, instance_id);
EXPECT_EQ(0u, instance_id);
rcl_reset_error();
instance_id = rcl_node_get_rcl_instance_id(&zero_node);
EXPECT_EQ(0, instance_id);
EXPECT_EQ(0u, instance_id);
rcl_reset_error();
instance_id = rcl_node_get_rcl_instance_id(&invalid_node);
EXPECT_NE(0, instance_id);
EXPECT_NE(42, instance_id);
EXPECT_NE(0u, instance_id);
EXPECT_NE(42u, instance_id);
rcl_reset_error();
start_memory_checking();
assert_no_malloc_begin();
@ -245,7 +245,7 @@ TEST_F(TestNodeFixture, test_rcl_node_accessors) {
assert_no_realloc_end();
assert_no_free_end();
stop_memory_checking();
EXPECT_NE(0, instance_id);
EXPECT_NE(0u, instance_id);
}
/* Tests the node life cycle, including rcl_node_init() and rcl_node_fini().

View file

@ -184,12 +184,12 @@ TEST_F(TestRCLFixture, test_rcl_init_and_ok_and_shutdown) {
TEST_F(TestRCLFixture, test_rcl_get_instance_id_and_ok) {
rcl_ret_t ret;
// Instance id should be 0 before rcl_init().
EXPECT_EQ(0, rcl_get_instance_id());
EXPECT_EQ(0u, rcl_get_instance_id());
ASSERT_FALSE(rcl_ok());
// It should still return 0 after an invalid init.
ret = rcl_init(1, nullptr, rcl_get_default_allocator());
EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, ret);
EXPECT_EQ(0, rcl_get_instance_id());
EXPECT_EQ(0u, rcl_get_instance_id());
ASSERT_FALSE(rcl_ok());
// A non-zero instance id should be returned after a valid init.
{
@ -207,13 +207,13 @@ TEST_F(TestRCLFixture, test_rcl_get_instance_id_and_ok) {
assert_no_malloc_end();
assert_no_realloc_end();
assert_no_free_end();
EXPECT_NE(0, first_instance_id);
EXPECT_NE(0u, first_instance_id);
EXPECT_EQ(first_instance_id, rcl_get_instance_id()); // Repeat calls should return the same.
EXPECT_EQ(true, rcl_ok());
// Calling after a shutdown should return 0.
ret = rcl_shutdown();
EXPECT_EQ(ret, RCL_RET_OK);
EXPECT_EQ(0, rcl_get_instance_id());
EXPECT_EQ(0u, rcl_get_instance_id());
ASSERT_FALSE(rcl_ok());
// It should return a different value after another valid init.
{
@ -222,12 +222,12 @@ TEST_F(TestRCLFixture, test_rcl_get_instance_id_and_ok) {
EXPECT_EQ(RCL_RET_OK, ret);
ASSERT_TRUE(rcl_ok());
}
EXPECT_NE(0, rcl_get_instance_id());
EXPECT_NE(0u, rcl_get_instance_id());
EXPECT_NE(first_instance_id, rcl_get_instance_id());
ASSERT_TRUE(rcl_ok());
// Shutting down a second time should result in 0 again.
ret = rcl_shutdown();
EXPECT_EQ(ret, RCL_RET_OK);
EXPECT_EQ(0, rcl_get_instance_id());
EXPECT_EQ(0u, rcl_get_instance_id());
ASSERT_FALSE(rcl_ok());
}

View file

@ -66,7 +66,7 @@ TEST_F(TestTimeFixture, test_rcl_system_time_point_now) {
assert_no_free_end();
stop_memory_checking();
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string_safe();
EXPECT_NE(now.nanoseconds, 0);
EXPECT_NE(now.nanoseconds, 0u);
// Compare to std::chrono::system_clock time (within a second).
now = {0};
ret = rcl_system_time_point_now(&now);
@ -99,7 +99,7 @@ TEST_F(TestTimeFixture, test_rcl_steady_time_point_now) {
assert_no_free_end();
stop_memory_checking();
EXPECT_EQ(ret, RCL_RET_OK) << rcl_get_error_string_safe();
EXPECT_NE(now.nanoseconds, 0);
EXPECT_NE(now.nanoseconds, 0u);
// Compare to std::chrono::steady_clock difference of two times (within a second).
now = {0};
ret = rcl_steady_time_point_now(&now);

View file

@ -43,9 +43,9 @@ TEST(TestMemoryTools, test_allocation_checking_tools) {
ASSERT_NE(remem, nullptr);
if (!remem) {free(mem);}
free(remem);
EXPECT_EQ(unexpected_mallocs, 0);
EXPECT_EQ(unexpected_reallocs, 0);
EXPECT_EQ(unexpected_frees, 0);
EXPECT_EQ(unexpected_mallocs, 0u);
EXPECT_EQ(unexpected_reallocs, 0u);
EXPECT_EQ(unexpected_frees, 0u);
// Enable checking, but no assert, should have no effect.
start_memory_checking();
mem = malloc(1024);
@ -54,9 +54,9 @@ TEST(TestMemoryTools, test_allocation_checking_tools) {
ASSERT_NE(remem, nullptr);
if (!remem) {free(mem);}
free(remem);
EXPECT_EQ(unexpected_mallocs, 0);
EXPECT_EQ(unexpected_reallocs, 0);
EXPECT_EQ(unexpected_frees, 0);
EXPECT_EQ(unexpected_mallocs, 0u);
EXPECT_EQ(unexpected_reallocs, 0u);
EXPECT_EQ(unexpected_frees, 0u);
// Enable no_* asserts, should increment all once.
assert_no_malloc_begin();
assert_no_realloc_begin();
@ -70,9 +70,9 @@ TEST(TestMemoryTools, test_allocation_checking_tools) {
if (!remem) {free(mem);}
free(remem);
assert_no_free_end();
EXPECT_EQ(unexpected_mallocs, 1);
EXPECT_EQ(unexpected_reallocs, 1);
EXPECT_EQ(unexpected_frees, 1);
EXPECT_EQ(unexpected_mallocs, 1u);
EXPECT_EQ(unexpected_reallocs, 1u);
EXPECT_EQ(unexpected_frees, 1u);
// Enable on malloc assert, only malloc should increment.
assert_no_malloc_begin();
mem = malloc(1024);
@ -82,9 +82,9 @@ TEST(TestMemoryTools, test_allocation_checking_tools) {
ASSERT_NE(remem, nullptr);
if (!remem) {free(mem);}
free(remem);
EXPECT_EQ(unexpected_mallocs, 2);
EXPECT_EQ(unexpected_reallocs, 1);
EXPECT_EQ(unexpected_frees, 1);
EXPECT_EQ(unexpected_mallocs, 2u);
EXPECT_EQ(unexpected_reallocs, 1u);
EXPECT_EQ(unexpected_frees, 1u);
// Enable on realloc assert, only realloc should increment.
assert_no_realloc_begin();
mem = malloc(1024);
@ -94,9 +94,9 @@ TEST(TestMemoryTools, test_allocation_checking_tools) {
ASSERT_NE(remem, nullptr);
if (!remem) {free(mem);}
free(remem);
EXPECT_EQ(unexpected_mallocs, 2);
EXPECT_EQ(unexpected_reallocs, 2);
EXPECT_EQ(unexpected_frees, 1);
EXPECT_EQ(unexpected_mallocs, 2u);
EXPECT_EQ(unexpected_reallocs, 2u);
EXPECT_EQ(unexpected_frees, 1u);
// Enable on free assert, only free should increment.
assert_no_free_begin();
mem = malloc(1024);
@ -106,9 +106,9 @@ TEST(TestMemoryTools, test_allocation_checking_tools) {
if (!remem) {free(mem);}
free(remem);
assert_no_free_end();
EXPECT_EQ(unexpected_mallocs, 2);
EXPECT_EQ(unexpected_reallocs, 2);
EXPECT_EQ(unexpected_frees, 2);
EXPECT_EQ(unexpected_mallocs, 2u);
EXPECT_EQ(unexpected_reallocs, 2u);
EXPECT_EQ(unexpected_frees, 2u);
// Go again, after disabling asserts, should have no effect.
mem = malloc(1024);
ASSERT_NE(mem, nullptr);
@ -116,9 +116,9 @@ TEST(TestMemoryTools, test_allocation_checking_tools) {
ASSERT_NE(remem, nullptr);
if (!remem) {free(mem);}
free(remem);
EXPECT_EQ(unexpected_mallocs, 2);
EXPECT_EQ(unexpected_reallocs, 2);
EXPECT_EQ(unexpected_frees, 2);
EXPECT_EQ(unexpected_mallocs, 2u);
EXPECT_EQ(unexpected_reallocs, 2u);
EXPECT_EQ(unexpected_frees, 2u);
// Go once more after disabling everything, should have no effect.
stop_memory_checking();
mem = malloc(1024);
@ -127,7 +127,7 @@ TEST(TestMemoryTools, test_allocation_checking_tools) {
ASSERT_NE(remem, nullptr);
if (!remem) {free(mem);}
free(remem);
EXPECT_EQ(unexpected_mallocs, 2);
EXPECT_EQ(unexpected_reallocs, 2);
EXPECT_EQ(unexpected_frees, 2);
EXPECT_EQ(unexpected_mallocs, 2u);
EXPECT_EQ(unexpected_reallocs, 2u);
EXPECT_EQ(unexpected_frees, 2u);
}