-
Notifications
You must be signed in to change notification settings - Fork 392
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
Iox #261 Replace std::terminate with Expects/Ensures #750
Iox #261 Replace std::terminate with Expects/Ensures #750
Conversation
…x_utils Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
…ceoryx_posh Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
…cator changes and move makeScopedStatic to inl Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
Codecov Report
@@ Coverage Diff @@
## master #750 +/- ##
==========================================
+ Coverage 74.03% 74.22% +0.19%
==========================================
Files 319 320 +1
Lines 11426 11416 -10
Branches 1972 1973 +1
==========================================
+ Hits 8459 8474 +15
+ Misses 2192 2165 -27
- Partials 775 777 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Please try to avoid the usage of cxx::Expects
and cxx::Ensures
as much as possible. I think they should only be used when you encounter an error from which you can not recover or where it is impossible for you to continue.
Please try to use cxx::expected
as often as possible. The reasons are:
- the compiler will force the user to perform some error handling. When you use
cxx::Expects
/cxx::Ensures
the user will most likely be not aware that the program can terminate under certain conditions. - If you use
cxx::expected
the error is baked into the signature and documented - When you use
cxx::Expects/Ensures
you have to document this in a doxygen note or somewhere in the brief section. This can be easily be overlooked, by us when we refactor the code, by the user when they use the code.
The last point is demonstrated well in this PR, since in most of the doxygen docu it is nowhere mentioned that the methods which are using cxx::Expects
/cxx::Ensures
can be lead to fatal process termination.
#include <assert.h> | ||
#include <cstdint> | ||
#include <iostream> | ||
#include <limits> | ||
#include <type_traits> | ||
|
||
#include "iceoryx_utils/platform/platform_correction.hpp" |
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.
Nice! Thanks, the platform correction has to be always the last include to cleanup the mess which other platforms produce.
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.
since iceoryx is a library, are we sure we don't break others code with this? I also do not have a better solution for this, except not using most of the stuff in that header within iceoryx
@@ -0,0 +1,41 @@ | |||
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. |
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.
This is wrong. It was created today.
I know the first implementation was in 2019 in the helplets.hpp file but thanks to git the whole history is preserved and correct. Here we have some implicit assumptions which just lead directly into a weird and complex world.
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 but copyright does not rely on the Git history. This file was copied and pasted and not written by me. As a result all copyright information has to be copied to new file as well. It's done like this in every FOSS project I've worked on.
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.
@mossmaurice I strongly disagree. @elBoberido , @dkroenke , @budrus @FerdinandSpitzschnueffler @MatthiasKillat what do you think?
The reason is the following. Let's assume you are right then everytime we do some refactoring and move a function into a new file we have to trace the whole function. This means when it was first written in file A, then moved to file B, then to file C and with the new refactoring to file D we have to trace the git history of the function through the files. In the new file we have then to add all the people who ever touched a piece of the function in the copyright header.
It is getting even worse when we would like to split up the function in the next refactoring in to different files. Then we have to trace every line!!! With every file we create and move code we have trace all the lines where they did come from! This is absolutely horrible.
Please do not close or resolve the conversation until we all agreed on how we proceed in such cases.
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.
@elfenpiff @mossmaurice
Well, looking at the Eclipse Handbook could maybe clarify this: https://www.eclipse.org/projects/handbook/#legaldoc-faq
How do file headers change when content is refactored?
When you split a file during a refactoring exercise, any new files that you create must automatically inherit the header of the original. If even fragment of text from a single line of the original content survives the refactoring (whether generated, rote, or otherwise), then the original copyright statement and author information should be retained.
Even a refactoring exercise that does not change behaviour, may add intellectual property. When refactoring adds content, copyright statements should be updated to reflect the addition. In concrete terms, you can either add the new copyright holders to the existing copyright statement or append "and others" (especially when the list of copyright holders gets long).
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.
Ok, thanks @dkroenke for clarifying this. If we should get into a situation with dozens of copyright holder we might switch to "and others". We can raise awareness about this topic in the next dev meetup.
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.
@mossmaurice @dkroenke How do we ensure the correctness of the copyright headers as a reviewer? Do we have to retrace the code lines and functions over the total git history? Or anyone else?
At the moment we can handle this somehow but when there will be more this is the ultimate time killer.
iceoryx_utils/include/iceoryx_utils/internal/posix_wrapper/mutex.hpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
…m entry Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
…s calls Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
…back() Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
} | ||
m_mgmtSegmentId = maybeMgmtSegmentId.value(); | ||
|
||
if (fatalError) |
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.
nitpicking, fatalError
could be anything and if someone extends this method with another fatal error that Person could accidentally also use this flag even if it's a totally different error. How about using a lambda
auto handlePreconditionNotFulfilled = [] (bool preconditionNotFulfilled, const char* message) {
if (preconditionNotFulfille)
{
LogFatal() << message;
/// @todo #539 Use separate error enums once RouDi is more modular
errorHandler(Error::kROUDI__PRECONDITIONS_FOR_PROCESS_MANAGER_NOT_FULFILLED, nullptr, ErrorLevel::FATAL);
}
};
handlePreconditionNotFulfilled(!maybeSegmentManager.has_value(), "Invalid state! Could not obtain SegmentManager!");
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 see your point, but IMHO the maintenance effort is not much higher, hence I'll stick with the current approach as this will be refactored relatively soon anyway.
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.
it's your decision, but keep in mind, nothing is more definitive than the temporary ;)
#include <assert.h> | ||
#include <cstdint> | ||
#include <iostream> | ||
#include <limits> | ||
#include <type_traits> | ||
|
||
#include "iceoryx_utils/platform/platform_correction.hpp" |
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.
since iceoryx is a library, are we sure we don't break others code with this? I also do not have a better solution for this, except not using most of the stuff in that header within iceoryx
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
…e and simplify out of bounds check in cxx::vector Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
…turn value of AccessController::createACL() Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
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.
Please place the termination comments directly into the function/method documentation and then you get my thumbs up :)
iceoryx_utils/include/iceoryx_utils/internal/posix_wrapper/mutex.hpp
Outdated
Show resolved
Hide resolved
…o termination Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
iceoryx_utils/include/iceoryx_utils/internal/posix_wrapper/mutex.hpp
Outdated
Show resolved
Hide resolved
…r, use attention doxygen tag and remove redundant comments Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
iceoryx_utils/include/iceoryx_utils/internal/posix_wrapper/access_control.hpp
Show resolved
Hide resolved
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
Pre-Review Checklist for the PR Author
iox-#123-this-is-a-branch
)iox-#123 commit text
)git commit -s
)task-list-completed
)Notes for Reviewer
std::terminate
withExpects
/Ensures
orerrorHandler()
makeScopedStatic()
to its own hpp / inlChecklist for the PR Reviewer
Post-review Checklist for the PR Author
References