The thread.enabled is checked multiple times in controller_thread_is_enabled() but this value may have changed.
Make a constant copy and reference that copy so that any changes after the first read will not affect the function results.
#ifndef _di_controller_thread_is_enabled_
f_status_t controller_thread_is_enabled(const bool is_normal, controller_thread_t * const thread) {
- if (is_normal) {
- return thread->enabled == controller_thread_enabled_e;
- }
+ const bool enabled = thread->enabled;
- return thread->enabled;
+ return is_normal ? enabled == controller_thread_enabled_e : enabled;
}
#endif // _di_controller_thread_is_enabled_