-
Notifications
You must be signed in to change notification settings - Fork 648
system/settings: general code cleaning #3110
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
Conversation
* Remove duplicate checks, use switch/case whenever possible * Remove assertions just before if () condition checking the exact same thing * Replace if (condition) assert(0) with assert(condition) Signed-off-by: Jean THOMAS <jean@lambdaconcept.com>
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.
Thank you @jeanthom :-)
- Please take a look at my notes in the code to make sure all will work as expected after change :-)
- There is a slight behavioral change introduced for instance no asserts but error code return which seems okay :-)
- How did you verify the change? Could you please provide testing logs from a real hardware before and after?
Hi @cederom and thanks for your review. I applied the required suggestions to the code. Regarding the behavioral change, I think it is sensible: I was always told asserts should be used to verify internal state of a program whereas error code should be preferred to notify an issue with user input. Regarding tests: ran the example "settings" app using sim:nsh NuttX configuration. Before:
After:
|
@TimJTi since you are the original author, please take a look too! |
Actually - I didn't write it but did "port" it to NuttX and am using it regularly. Once it is reviewed by others and "ready to merge" give me the heads up and all merge the PR in to my code and make sure it works OK for me still. Or are we there now? The original author was very keen I messed with as little as possible when I was making it "suitable for NuttX", and got me to "undo" things I'd changed (perhaps including better use of select/case rather than if/elseif/else etc!!! Can't please everybodt all the time LOL. As far as assert vs error code: having both means that if NDEBUG is set, disabling asserts, there are still error messages, but the program doesn't "crash" as such. I have seen this used in quite a few places and it seemed a good idea at the time, and is "benign"; but if its frowned upon here, so be it - although nobody complained during the reviews when I submitted the 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.
Thanks @jeanthom for all the updates and feedback, just one bracket inside case and we are ready to go :-)
ca22f54
to
bdcf141
Compare
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.
Thank you @jeanthom :-)
Tim you can clone the source repo switch to branch that constitutes this PR build and see if that works for you :-) If you have existing application that uses settings you may want to build that too and see if anything is broken and works as expected - all should work fine with your existing application. Thank you :-) I have dedicated nuttx/pr/nuttx.git and nuttx/pr/nuttx-apps.git clones where I add remotes to be tested, here is an example:
|
Thanks @cederom And I see nicely "quoted" added/deleted lines that are then commented on (and in the past I have seen suggested changes that can be accepted here). Is that done manually from the git change log or is there a "trick" to that too? |
If you are talking about discussion here on GitHub regarding specific lines changed then this is part of the PR processing interface on GitHub website :-) You go to "files changed" top tab under PR, then when you point to a line number either on the |
@TimJTi normally I do this way: https://acassis.wordpress.com/2022/02/24/how-to-test-a-pr-before-it-get-integrated-on-nuttx/ |
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.
Much neater than the original that I worked from! Nice work 👍
Nothing broken that I've found with brief testing in my project- I can raise a new issue or PR if I do find anything not right in the future but it looks to be good to go.
Thank you @jeanthom ! |
Summary
Impact
No impact on users.
Testing
Ran the example "settings" app using sim:nsh NuttX 12.9.0 configuration.
Before:
After: