-
Notifications
You must be signed in to change notification settings - Fork 404
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
Fix convert edge cases #2135
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2135 +/- ##
==========================================
- Coverage 80.22% 80.12% -0.11%
==========================================
Files 418 418
Lines 16172 16218 +46
Branches 2255 2251 -4
==========================================
+ Hits 12974 12994 +20
- Misses 2399 2420 +21
- Partials 799 804 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Thanks for the PR. I'll have a closer look tomorrow at the changes but I'm quite happy that the out parameters are soon a thing of the past :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not yet fully review the tests and convert.inl. Just had a remark regarding the newly introduced alwaysSuccess
. Will finish the review tomorrow.
I think we (and always when I say we I actually mean you :) ) also need to add tests for the corner cases this PR fixes. If you think it will blow the PR up too much, it could also be done in a follow up PR.
Rename `fromString` to `from_string`. Note that the name of test cases are not included. Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Remove dest for numeric conversion. Now, the part of `for_string` will return iox::optional. Also, we introduce `validate_return_value` and `check_edge_case` to simplify the code of checking. The former can be used to return an iox::optional object while the latter is used in the former to check whether any conversion failure happened. Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
The from_string API has been updated. It now returns an iox::optional of the specified target value type, and the dest parameter has been removed. Subsequently, functions that utilize from_string have been restructured to accommodate the new calling format. Some of these functions now require default values for the value_or method, but I am uncertain whether these default values are appropriate. A new function named forceOkReturnValue has been introduced (the name may be subject to change later). This function addresses a specific issue encountered with uint64_t cases. Previously, we used failureReturnValue(ULLONG_MAX), which incorrectly flagged the valid conversion case of "18446744073709551615" as a failure. With forceOkReturnValue, the condition call.has_error() should consistently return false for this scenario. The accuracy of the conversion result is now assessed within the check_edge_case function. As a note, areas marked with @todo iox-eclipse-iceoryx#2055 still require modifications, most of which pertain to documentation. These will be addressed in the upcoming commit. Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
In iceoryx_posh/source/runtime/posh_runtime_impl.cpp, convert::from_string are used to convert the segment id and offset. However, the conversion failure might occur. Therefore, an new error type: `SEGMENT_ID_OR_OFFSET_CONVERSION_FAILURE` are introduced to be utilized as an error return value, reminding user a conversion failure happened in posh runtime. Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
1c377a8
to
809dddc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Mostly nitpicks and a few new tests for the edge cases needs to be written :)
Change the template args of specialization of `from_string` from length fixed type to basic type. Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Function named `convert_id_and_offset` was created. Signed-off-by: Dennis Liu <[email protected]>
Now, `is_valid_errno` will also print the string that cause failure. Signed-off-by: Dennis Liu <[email protected]>
It seems that there are some errors occurring during the execution of |
I think you forgot |
Signed-off-by: Dennis Liu <[email protected]>
- Add long and unsigned long specialization for from_string. - Remove deprecated `is_iox_string` and `GetCapacity`. - Move the specialization of std::string to `iox/std_string_support.hpp`. - Replace `enable_if_t` by `if constexpr` branch. Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
- Add a todo in `is_valid_errno`. - Clean `errno` before leaving from `evaluate return value`. Signed-off-by: Dennis Liu <[email protected]>
Modify the target function of the `IOX_POSIX_CALL` invocation, and for those that might encounter an edge case error due to the invocation of `failureReturnValue`, replace it with `alwaysSuccess`. Specifically, this applies to unsigned/signed types: `long long`, `long`, and `int` (for 32-bit systems). Please note that we assume `int` is always 4 bytes, and `long long` is definitively 8 bytes. Signed-off-by: Dennis Liu <[email protected]>
If there are no other issues with the aforementioned modifications, I think we can start adding some edge cases for testing purposes. |
I did not yet look at the code but I don't expect any issues. Feel free to start whenever it pleases you :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I gave you bad advice with suppressErrorMessagesForErrnos
. With ignoreErrnos
the alwaysSuccess
method can be removed.
Except that there are just a few minor things like not having to explicitely cache the errno because it is already done in the result of the posix call.
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think now is everything covered. The check for signaling NAN can be removed. Sorry for that :)
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for some additional tests to check for the edge cases this looks now great.
From my point of view the new tests could also be added in a new PR if you think this one is already overloaded. I leave it to you.
Thank you for your review. I would like to create a new PR. Our conversation on this PR has already been quite lengthy, and I believe there will be more to discuss when testing edge cases. Therefore, I think we should start a new PR focused on conducting tests for edge cases :) |
Merging this PR. All the old tests pass and additional tests for corner cases will be added in a separate PR |
Pre-Review Checklist for the PR Author
iox-123-this-is-a-branch
)iox-#123 commit text
)task-list-completed
)iceoryx_hoofs
are added to./clang-tidy-diff-scans.txt
Notes for Reviewer
I'm not sure the values of new
IOX_2055_WORKAROUND
s are proper or not. Please check them.Checklist for the PR Reviewer
iceoryx_hoofs
have been added to./clang-tidy-diff-scans.txt
Post-review Checklist for the PR Author
References