-
Notifications
You must be signed in to change notification settings - Fork 102
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
Remove failure check of RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED #257
Conversation
Signed-off-by: Stephen Brawner <[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.
While looking for places to increase testing coverage, I noticed that logic in logging.c required the
rcutils_get_env
call for RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED to at least succeed. As currently implemented, it will always succeed and return NULL thus the else statement is dead code. But even if it could result in an error, the else clause doesn't seem useful since the environment variable use has been deprecated.
While I understand that this is hard to test from a testing point-of-view, the conditions it is checking for are different. One is the unexpected case where rcutils_get_env
returned an error; if that occurs, then something very bad is happening and most likely other things are going to fail later too. In that case, it seems better to get out early and fail the program.
The other case is the one in where rcutils_get_env
succeeded, but the variable was non-empty, so we want to print a warning message. This is more-or-less expected as a backwards-compatibility thing, so we should just print the warning and continue.
With that being said, I don't think this implementation is right. I think the second clause that was already there is actually providing a bit of value.
In the case where i.e.
|
Oh, I see. Yeah, for right now, you are correct. But we are looking at changing the signature of While I don't usually like to hold code up on something that may happen in the future, in this case it will be pretty easy to forget that we baked this knowledge in here. So in the name of defensive programming, I'd still suggest that we keep the distinction between something going wrong in the system and the thing being empty. |
I just wanted to float this PR as an idea. I realize that a lot of repetitive checks are happening in the code base and I don't have a problem with that. This just seemed like a situation where if the API of |
While looking for places to increase testing coverage, I noticed that logic in logging.c required the
rcutils_get_env
call for RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED to at least succeed. As currently implemented, it will always succeed and return NULL thus the else statement is dead code. But even if it could result in an error, the else clause doesn't seem useful since the environment variable use has been deprecated.Importantly for foxy considerations, this will not change the API of the function, since the environment variable was unused and the rcutils_get_env call will always succeed.
colcon build --packages-up-to rcutils && colcon test --packages-select rcutils
Signed-off-by: Stephen Brawner [email protected]