-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Reduce a few LOC in rcS AUTOCNF logic #12467
Conversation
ROMFS/px4fmu_common/init.d/rcS
Outdated
fi | ||
|
||
# | ||
# Optional board defaults: rc.board_defaults | ||
# | ||
set BOARD_RC_DEFAULTS /etc/init.d/rc.board_defaults |
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.
Keeping the scope of these more local is IMO preferrable, as it makes it easier to track the variable state, and reduces memory usage.
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.
Hi@bkueng! Thanks for your feedback. I understand your point and agree with keeping variables as close as possible to where they are used as a general rule to follow. The trouble with the startup scripts is accounting for variables to ensure they get unset
. For variables that get set/unset within a few LOC, this is easy, but for variables that are used by multiple startup files this becomes a headache. I realize that for this PR the set/unsets are close together, I am primarily motivated by employing a standard practice that is easily identifiable and helps reduce errors in the future in this PR.
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's totally acceptable if you'd prefer to keep the existing. Not a problem at all to close out this PR unmerged, I understand where you are coming from.)
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.
I generally agree, but for these specific instances I prefer the existing way (for the same reasons you already mention).
Flight tested: https://review.px4.io/plot_app?log=79c9686b-0dad-41d3-bad2-558b5b16ac1c Bench test:
EDIT: Set
|
…w LOC checking SYS_AUTOCONFIG with improved logic.
…ly the SYS_AUTOCONFIG logic modification.
Hi @bkueng , I've replaced the set/unset(s), leaving only the SYS_AUTOCONFIG logic modifications. Here are the results from relevant console output from master and this PR, behavior is identical. PX4:master:
This PR:
|
then | ||
set AUTOCNF yes | ||
else | ||
set AUTOCNF no |
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.
I don't see this set to no
in the else case anymore. If not set, it could cause problems with script evaluation.
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.
Thanks for catching that. That deletion shouldn't have occurred. The unset remains at the bottom of the script, but the script still lacks a single design pattern in that regard. By the logic we've discussed above the set/unset for AUTOCNF should probably be moved to this location, but then we'd slowly end up where we were last year with variables not getting unset. My preference would still be a single rule to follow.
Thanks @bkueng ! |
Describe problem solved by the proposed pull request
This PR simplifies the rcS script
SYS_AUTOCONFIG
logic and drops a few LOC. It also moves set/unset statements in the script to the top and bottom as housekeeping and saves about 50 bytes of flash.Test data / coverage
The logic change is easily examined by inspection. The set/unset copy/paste is also easily examined by inspection.
Describe possible alternatives
If this PR isn't helpful, please feel free to close it!
Thanks!