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

mavros_extras: Fix a sequence point warning #1808

Merged
merged 1 commit into from
Nov 30, 2022

Conversation

mortenfyhn
Copy link
Contributor

This line triggers a -Wsequence-point warning. You can read about it here: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

It seems to be that doing ++ (which modifies a variable) and assigning the result back to the same variable can be undefined behaviour.

In this case, we don't need to pre-increment, we can just add one, and then save the result back to the variable. This makes the warning go away, and seems to make sense.

@vooon vooon added this to the Version 1.15 milestone Nov 30, 2022
Copy link
Member

@vooon vooon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@vooon vooon merged commit 9b793d1 into mavlink:master Nov 30, 2022
@mortenfyhn mortenfyhn deleted the fix-sequence-point-warning branch November 30, 2022 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants