Skip to content

Commit

Permalink
[rcl_yaml_param_parser] Add warnings (ros2#831)
Browse files Browse the repository at this point in the history
* Add warnings

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

* Fix conversion warning by casting to size_t

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

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
add_compile_options(
-Wall -Wextra -Wpedantic
-Wformat=2 -Wconversion -Wsign-conversion
)
endif()

set(rcl_yaml_parser_sources
Expand Down
4 changes: 2 additions & 2 deletions rcl_yaml_param_parser/src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ _validate_name(const char * name, rcutils_allocator_t allocator)
}
} else {
// substring namespace including the last '/'
char * namespace_ = rcutils_strndup(name, separator_pos - name + 1, allocator);
char * namespace_ = rcutils_strndup(name, ((size_t) (separator_pos - name)) + 1, allocator);
if (NULL == namespace_) {
ret = RCUTILS_RET_BAD_ALLOC;
goto clean;
Expand Down Expand Up @@ -534,7 +534,7 @@ _validate_name(const char * name, rcutils_allocator_t allocator)
}
} else {
do {
size_t len = separator_pos - absolute_namespace - i;
size_t len = ((size_t) (separator_pos - absolute_namespace)) - i;
char * namespace_ = rcutils_strndup(absolute_namespace + i, len, allocator);
if (NULL == namespace_) {
ret = RCUTILS_RET_BAD_ALLOC;
Expand Down

0 comments on commit 1f5a713

Please sign in to comment.