-
Notifications
You must be signed in to change notification settings - Fork 127
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
Global use of nodiscard #801
Conversation
Signed-off-by: CursedRock17 <[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.
lgtm.
IMO this is better. Once we can have a consensus to go this path, i can help this.
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.
In general, I'm for changes like this where we can do it; we have similar macros in C (https://github.com/ros2/rcutils/blob/2773c6069b844bc7866dc2199827784d0aac7f28/include/rcutils/macros.h#L25-L31).
That said, we need to run full CI with this in place. I think we'll end up finding a few places here and there that don't check the return value.
I think we want to do it on a repository-by-repository basis regardless, so this PR is a good start.
I'm fine with extending it as far as it makes sense.
Yeah, so we wouldn't add |
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 looks to me like this is all happy with the downstream. And the issues on CI are known issues, unrelated to this PR. So I'm going to go ahead and merge this one in, thanks @CursedRock17
Ah, sorry, scratch that. So, it turns out that we cannot update the |
Signed-off-by: CursedRock17 <[email protected]>
Interesting, one thing I was contemplating on touching on was inside of the |
It's not necessarily a problem; I'd be OK with adding that. But we just have to make sure that the Either way, I think we should do it in a separate PR; this one is almost good to go (just need to run CI on it one more time). |
This PR is meant to address #786 in the
rosidl
repo, so usingnodiscard
on any getter functions and operators if possible. Addingnodiscard
should prevent a lot of unnecessary bugs ahead of time. Though, I do have a couple things that we may need to addressnodiscard
? At the original release of this PR I just went for getters and operators because of the implementation details:Though realistically many functions could utilize
nodiscard
to prevent weird issues.*this
cannot usenodiscard
because you must always assign thatthis
value but each operator overload hasnodiscard
, so we would have to make extra functions which don't usenodiscard
, getting rid of the purpose.