(tidy)driver_buses: fix unused variable error#48
Merged
brianredbeard merged 1 commit intomasterfrom May 19, 2023
Merged
Conversation
Previously, the `cppcheck` tool reported an error in the `start_buses` function of `buses.c` due to the structure of its macro definitions. The goal was to initialize a value to capture the return state when initializing various buses on the host. If a bus (FOO) was exposed through a macro set by Kconfig, an attempt would be made to initialize the FOO bus. If the attempt failed, the `start_buses` function would immediately return the ESP32 error status from FOO. If the attempts succeeded, `start_buses` would return a static definition of "ESP_OK." However, the use of macros by the compiler's preprocessor introduced non-determinism for static analysis tools, leading to ambiguity regarding the use of `res`. This commit slightly changes the behavior by initializing `res` to the desired resulting value, "ESP_OK," and returning `res` instead of "ESP_OK." If any of the buses fail to initialize, the value of `res` will be overwritten, after which the behavior will remain the same.
renzenicolai
approved these changes
May 18, 2023
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.
Previously, the
cppchecktool reported an error in thestart_busesfunction ofbuses.cdue to the structure of its macro definitions. The goal was to initialize a value to capture the return state when initializing various buses on the host. If a bus (FOO) was exposed through a macro set by Kconfig, an attempt would be made to initialize the FOO bus. If the attempt failed, thestart_busesfunction would immediately return the ESP32 error status from FOO. If the attempts succeeded,start_buseswould return a static definition of "ESP_OK."However, the use of macros by the compiler's preprocessor introduced non-determinism for static analysis tools, leading to ambiguity regarding the use of
res.This commit slightly changes the behavior by initializing
resto the desired resulting value, "ESP_OK," and returningresinstead of "ESP_OK." If any of the buses fail to initialize, the value ofreswill be overwritten, after which the behavior will remain the same.