On 5/2/2025 7:24 PM, Konrad Dybcio wrote:
On 5/2/25 2:22 PM, Bryan O'Donoghue wrote:
On 01/05/2025 20:13, Dikshita Agarwal wrote:
- if (core->state == IRIS_CORE_ERROR) + if (core->state == IRIS_CORE_ERROR || core->state == IRIS_CORE_DEINIT) return -EINVAL;
Instead of checking for 2/3 of the states why not just check for the 1/3 ?
enum iris_core_state { IRIS_CORE_DEINIT, IRIS_CORE_INIT, IRIS_CORE_ERROR, };
if (core->state != IRIS_CORE_INIT) return -EINVAL;
Cleaner and more explicit - declaring the state you must be in, as opposed to a list of states you should not be in.
Being explicit in state machines helps maintainability - if we get e.g. IRIS_CORE_LIGHT_SLEEP down the line, this could easily fail
Agree, would prefer to keep the check as is if (core->state == IRIS_CORE_ERROR || core->state == IRIS_CORE_DEINIT)
Thanks, Dikshita
Konrad