Skip to content

(tidy)driver_buses: fix unused variable error#48

Merged
brianredbeard merged 1 commit intomasterfrom
unused-fix
May 19, 2023
Merged

(tidy)driver_buses: fix unused variable error#48
brianredbeard merged 1 commit intomasterfrom
unused-fix

Conversation

@brianredbeard
Copy link
Contributor

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.

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.
@brianredbeard brianredbeard added the chore Maintenance work not driving features label May 17, 2023
@brianredbeard brianredbeard merged commit 5a549a6 into master May 19, 2023
@brianredbeard brianredbeard deleted the unused-fix branch May 19, 2023 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance work not driving features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants