Skip to content

Commit

Permalink
[rcl_lifecycle] Add warnings (#830)
Browse files Browse the repository at this point in the history
* Add warnings

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>

* Use uint8_t for id in rcl_lifecycle_state_init

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>
  • Loading branch information
audrow authored Oct 21, 2020
1 parent e9c87e2 commit 5ef4b2d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion rcl_lifecycle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ if(NOT CMAKE_CXX_STANDARD)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
add_compile_options(
-Wall -Wextra -Wpedantic
-Wformat=2 -Wconversion -Wshadow -Wsign-conversion
)
endif()

set(rcl_lifecycle_sources
Expand Down
2 changes: 1 addition & 1 deletion rcl_lifecycle/include/rcl_lifecycle/data_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef struct rcl_lifecycle_state_t
/// String with state name: Unconfigured, Inactive, Active or Finalized
const char * label;
/// Identifier of the state
unsigned int id;
uint8_t id;

/// Pointer to a struct with the valid transitions
rcl_lifecycle_transition_t * valid_transitions;
Expand Down
2 changes: 1 addition & 1 deletion rcl_lifecycle/include/rcl_lifecycle/rcl_lifecycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ RCL_WARN_UNUSED
rcl_ret_t
rcl_lifecycle_state_init(
rcl_lifecycle_state_t * state,
unsigned int id,
uint8_t id,
const char * label,
const rcl_allocator_t * allocator);

Expand Down
2 changes: 1 addition & 1 deletion rcl_lifecycle/src/rcl_lifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ rcl_lifecycle_get_zero_initialized_state()
rcl_ret_t
rcl_lifecycle_state_init(
rcl_lifecycle_state_t * state,
unsigned int id,
uint8_t id,
const char * label,
const rcl_allocator_t * allocator)
{
Expand Down
2 changes: 1 addition & 1 deletion rcl_lifecycle/test/test_rcl_lifecycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TEST(TestRclLifecycle, lifecycle_state) {
EXPECT_EQ(nullptr, state.label);

rcl_allocator_t allocator = rcl_get_default_allocator();
unsigned int expected_id = 42;
uint8_t expected_id = 42;
const char expected_label[] = "label";
rcl_ret_t ret = rcl_lifecycle_state_init(&state, expected_id, &expected_label[0], nullptr);
EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, ret);
Expand Down

0 comments on commit 5ef4b2d

Please sign in to comment.