Skip to content

Commit

Permalink
[nrf fromtree] net: wifi: Add an build assert for checking states order
Browse files Browse the repository at this point in the history
This helps us sanity check the enumerations order isn't changed.

Signed-off-by: Chaitanya Tata <[email protected]>
(cherry picked from commit cb331c2)
  • Loading branch information
krish2718 authored and rlubos committed Apr 8, 2024
1 parent e658f51 commit 35a3870
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/zephyr/net/wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 35a3870

Please sign in to comment.