net: wifi: Add an build assert for checking states order

This helps us sanity check the enumerations order isn't changed.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This commit is contained in:
Chaitanya Tata 2024-03-27 18:00:33 +05:30 committed by Fabio Baltieri
parent 159617c8f6
commit cb331c2371

View file

@ -138,6 +138,18 @@ enum wifi_iface_state {
WIFI_STATE_UNKNOWN
};
/* We rely on the strict order of the enum values, so, let's check it */
BUILD_ASSERT(WIFI_STATE_DISCONNECTED < WIFI_STATE_INTERFACE_DISABLED &&
WIFI_STATE_INTERFACE_DISABLED < WIFI_STATE_INACTIVE &&
WIFI_STATE_INACTIVE < WIFI_STATE_SCANNING &&
WIFI_STATE_SCANNING < WIFI_STATE_AUTHENTICATING &&
WIFI_STATE_AUTHENTICATING < WIFI_STATE_ASSOCIATING &&
WIFI_STATE_ASSOCIATING < WIFI_STATE_ASSOCIATED &&
WIFI_STATE_ASSOCIATED < WIFI_STATE_4WAY_HANDSHAKE &&
WIFI_STATE_4WAY_HANDSHAKE < WIFI_STATE_GROUP_HANDSHAKE &&
WIFI_STATE_GROUP_HANDSHAKE < WIFI_STATE_COMPLETED);
/** Helper function to get user-friendly interface state name. */
const char *wifi_state_txt(enum wifi_iface_state state);