generator/CPP11: Define message::LENGTH and ::MIN_LENGTH as uint8_t#1182
Open
mr3screen wants to merge 1 commit into
Open
generator/CPP11: Define message::LENGTH and ::MIN_LENGTH as uint8_t#1182mr3screen wants to merge 1 commit into
mr3screen wants to merge 1 commit into
Conversation
The mavlink wire format only allows payloads up to 255 bytes and no message has LENGTH or MIN_LENGTH set to a valuer greater than 255. The mavlink_finalize_message*() family of functions to serialize a message expect the arguments `uint8_t min_length` and `uint8_t length`. A developers might be unsure why they're passing two size_t values to a function expecting uint8_ts and whether they need to manually check handle cases where truncation might occur. With this change the types communicate no concern is needed. Fixes ArduPilot#1181
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The mavlink wire format only allows payloads up to 255 bytes and no message has LENGTH or MIN_LENGTH set to a valuer greater than 255. The mavlink_finalize_message*() family of functions to serialize a message expect the arguments
uint8_t min_lengthanduint8_t length. A developers might be unsure why they're passing two size_t values to a function expecting uint8_ts and whether they need to manually check handle cases where truncation might occur.With this change the types communicate no concern is needed.
Fixes #1181
I did not test this change.
Note: If you're concerned about future longer messages in the future where this change would create an overflow: C++11 added list initializations, which can be used to create compile errors, if the compile-time assigned value is larger than fits in the target type:
The generator could be changed to use that instead of