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

Fix for incorrect integer value conversion on Windows #1126

Merged
merged 2 commits into from Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion rcl_yaml_param_parser/src/parse.c
Expand Up @@ -151,7 +151,7 @@ void * get_value(
style != YAML_DOUBLE_QUOTED_SCALAR_STYLE)
{
errno = 0;
ival = strtol(value, &endptr, 0);
ival = strtoll(value, &endptr, 0);
if ((0 == errno) && (NULL != endptr)) {
if ((NULL != endptr) && (endptr != value)) {
MichaelOrlov marked this conversation as resolved.
Show resolved Hide resolved
if (('\0' != *value) && ('\0' == *endptr)) {
Expand Down
2 changes: 1 addition & 1 deletion rcl_yaml_param_parser/test/correct_config.yaml
Expand Up @@ -18,7 +18,7 @@ lidar_ns:
dy: 0.45
lidar_2:
ros__parameters:
id: 11
id: 992147483647
name: back_lidar
dy1: 0.003
is_back: false
Expand Down
3 changes: 2 additions & 1 deletion rcl_yaml_param_parser/test/test_parse_yaml.cpp
Expand Up @@ -92,7 +92,8 @@ TEST(test_parser, correct_syntax) {
param_value = rcl_yaml_node_struct_get("lidar_ns/lidar_2", "id", params);
ASSERT_TRUE(NULL != param_value) << rcutils_get_error_string().str;
ASSERT_TRUE(NULL != param_value->integer_value);
EXPECT_EQ(11, *param_value->integer_value);
// Make sure that we can correctly parse bigger than LONG_MAX = 2147483647 values
EXPECT_EQ(992147483647, *param_value->integer_value);
res = rcl_parse_yaml_value("lidar_ns/lidar_2", "id", "12", params);
EXPECT_TRUE(res) << rcutils_get_error_string().str;
ASSERT_TRUE(NULL != param_value->integer_value);
Expand Down