Commit 33f1c3b
committed
(tidy)driver_buses: fix unused variable error
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.1 parent 4bf1b7c commit 33f1c3b
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
0 commit comments