Skip to content

Commit e645892

Browse files
authored
Add sanity checks for ethernet config table and WLED_ETH_DEFAULT
Small helper for integrators by compile-time sanity checks: * WLED_NUM_ETH_TYPES is aligned with the boards table * WLED_ETH_DEFAULT is aligned with the boards table -> can be merged into 17.0.0, 16.0.0, and 0.15.x branch
1 parent 4ba60a6 commit e645892

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

wled00/network.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ const ethernet_settings ethernetBoards[] = {
177177
},
178178
};
179179

180+
// sanity checks for ethernet config table and WLED_ETH_DEFAULT
181+
static_assert((sizeof(ethernetBoards)/sizeof(ethernetBoards[0])) == WLED_NUM_ETH_TYPES, "WLED_NUM_ETH_TYPES does not match size of ethernetBoards[] table.");
182+
#ifdef WLED_ETH_DEFAULT
183+
static_assert(((WLED_ETH_DEFAULT) >= WLED_ETH_NONE) && ((WLED_ETH_DEFAULT) < WLED_NUM_ETH_TYPES), "WLED_ETH_DEFAULT is out of range.");
184+
#endif
185+
180186
bool initEthernet()
181187
{
182188
static bool successfullyConfiguredEthernet = false;

0 commit comments

Comments
 (0)