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 convert edge cases #2135

Merged
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6196d41
iox-#2055 Rename `fromString` to `from_string`
Dennis40816 Dec 11, 2023
4016555
iox-#2055 Remove `convert::stringIsNumber` related func
Dennis40816 Dec 11, 2023
60b7c79
iox-#2055 Add local variable `end_ptr`
Dennis40816 Dec 11, 2023
80d7830
iox-#2055 Add `suppressErrorMessagesForErrnos`
Dennis40816 Dec 12, 2023
d5043a5
iox-#2055 Update from_string API for numeric conversion
Dennis40816 Dec 13, 2023
1082cc5
iox-#2055 Rename to `evaluate_return_value`
Dennis40816 Dec 13, 2023
27b0562
iox-#2055 Modify from_string API
Dennis40816 Dec 13, 2023
aaeb4a9
iox-#2055 Add comment for functions
Dennis40816 Dec 14, 2023
1347500
iox-#2055 Add a new IpcMessageErrorType
Dennis40816 Dec 14, 2023
c171c7f
iox-#2055 Try to fix macos sanitizer problem
Dennis40816 Dec 14, 2023
31cdc64
iox-#2055 Try to fix uninitialize error
Dennis40816 Dec 14, 2023
0a3eb9f
iox-#2055 Fix MacOS and arm-none-eabi-gcc API
Dennis40816 Dec 14, 2023
734ac26
iox-#2055 Initialize variables
Dennis40816 Dec 14, 2023
c486577
iox-#2055 Remove unsed variables
Dennis40816 Dec 14, 2023
809dddc
iox-#2055 Refactor the usage of from_string - 1
Dennis40816 Dec 19, 2023
c9ffbf2
iox-#2055 Change the `from_string` template arg
Dennis40816 Dec 20, 2023
ee6121e
iox-#2055 Refactor roudi_cmd_line_parser.cpp
Dennis40816 Dec 20, 2023
dd422c2
iox-#2055 Refactor id and offset conversion
Dennis40816 Dec 20, 2023
be1ab23
iox-#2055 Improve error msg
Dennis40816 Dec 20, 2023
61232c1
iox-#2055 Use type alias to make code more concise
Dennis40816 Dec 21, 2023
3ff3c73
iox-#2055 Refine `from_string` specialization
Dennis40816 Dec 21, 2023
79cac77
iox-#2055 Replace post-increment with pre-increment
Dennis40816 Dec 21, 2023
5ab15f5
iox-#2055 Rename to SourceType and source_val
Dennis40816 Dec 21, 2023
640c010
iox-#2055 Use assertion for `has_value` check
Dennis40816 Dec 21, 2023
e83b76d
iox-#2055 Add a todo in `is_valid_errno`
Dennis40816 Dec 21, 2023
3afbea9
iox-#2055 Modify the function IOX_POSIX_CALL call
Dennis40816 Dec 21, 2023
3defd1e
iox-#2055 Remove alwaysSuccess
Dennis40816 Dec 24, 2023
809b9a9
iox-#2055 Remove unused comment code
Dennis40816 Dec 25, 2023
4706afe
iox-#2055 Remove errno_cache from 'evaluate_return_value'
Dennis40816 Dec 25, 2023
3801cf5
iox-#2055 Add 'is_signaling_nan'
Dennis40816 Dec 25, 2023
d3f692a
iox-#2055 Replace 'Destination' with 'TargetType'
Dennis40816 Dec 31, 2023
a24be4a
iox-#2055 Remove 'is_signaling_nan' and 'errno = 0'
Dennis40816 Dec 31, 2023
e02d08b
iox-#2055 Simplify underlying type by alias
Dennis40816 Dec 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions iceoryx_examples/iceperf/main_follower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ int main(int argc, char* argv[])
{
constexpr decltype(EXIT_SUCCESS) MOO{EXIT_SUCCESS};

uint64_t intensity{0U};
if (!iox::convert::fromString(optarg, intensity))
auto result = iox::convert::from_string<uint64_t>(optarg);
if (!result.has_value())
{
std::cerr << "Could not parse 'intensity' paramater!" << std::endl;
return EXIT_FAILURE;
}

const auto intensity = result.value();

if (intensity > 100)
{
std::cerr << "Too high moo 'intensity'!" << std::endl;
Expand Down
6 changes: 5 additions & 1 deletion iceoryx_examples/iceperf/main_leader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,16 @@ int main(int argc, char* argv[])
}
break;
case 'n':
if (!iox::convert::fromString(optarg, settings.numberOfSamples))
{
auto result = iox::convert::from_string<uint64_t>(optarg);
if (!result.has_value())
{
std::cerr << "Could not parse 'number-of-samples' paramater!" << std::endl;
return EXIT_FAILURE;
}
settings.numberOfSamples = result.value();
break;
}
default:
return EXIT_FAILURE;
};
Expand Down
8 changes: 3 additions & 5 deletions iceoryx_hoofs/cli/include/iox/cli/arguments.inl
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ namespace cli
template <typename T>
inline expected<T, Arguments::Error> Arguments::convertFromString(const Argument_t& stringValue) const noexcept
{
// @todo iox-#2055 there are edge cases which lead to not initializing the value even when the return value of
// 'fromString' is true; value initialization can be removed when #2055 is fixed
T value{};
if (!convert::fromString(stringValue.c_str(), value))
auto result = convert::from_string<T>(stringValue.c_str());
if (!result.has_value())
{
std::cout << "\"" << stringValue.c_str() << "\" could not be converted to the requested type" << std::endl;
return err(Error::UNABLE_TO_CONVERT_VALUE);
}
return ok(value);
return ok(result.value());
}

template <>
Expand Down
Loading
Loading