motion-logger: Do not use value passed unchecked to access array#3829
Open
smoe wants to merge 1 commit intoLinuxCNC:2.9from
Open
motion-logger: Do not use value passed unchecked to access array#3829smoe wants to merge 1 commit intoLinuxCNC:2.9from
smoe wants to merge 1 commit intoLinuxCNC:2.9from
Conversation
Contributor
|
IIRC, axis checks should also check the mask because you have, for example, XZA configs where Y-axis is effectively invalid. But you need to have access to the axis_mask in trajectory stat, The checks could also be slightly simplified as: // valid: zero inclusive, max exclusive
if (joint >= 0 && joint < EMCMOT_MAX_JOINTS) {
// valid, use joint as index
} else {
log_print("...invalid joint index %d. Valid range [0,%d]\n", joint, EMCMOT_MAX_JOINTS-1);
}And, why do you split lines on closing curly brace and an else clause? You'd normally write that as: if (bla) {
something();
} else { // <-- this line
something_else();
} |
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.
Please kindly have an extra eye on me setting <,<=,> correctly. Maybe these checks are not required because those checks are already performed elsewhere. Still, it feels weird to not perform such checks. The major question though is if enough is done if any such invalid number is observed.