From e6458922e111b1d2e22713abddf2edb571fc5126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20M=C3=B6hle?= <91616163+softhack007@users.noreply.github.com> Date: Tue, 12 May 2026 13:43:47 +0200 Subject: [PATCH] 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 --- wled00/network.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wled00/network.cpp b/wled00/network.cpp index e97bf70abd..2903628831 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -177,6 +177,12 @@ const ethernet_settings ethernetBoards[] = { }, }; +// sanity checks for ethernet config table and WLED_ETH_DEFAULT +static_assert((sizeof(ethernetBoards)/sizeof(ethernetBoards[0])) == WLED_NUM_ETH_TYPES, "WLED_NUM_ETH_TYPES does not match size of ethernetBoards[] table."); +#ifdef WLED_ETH_DEFAULT + static_assert(((WLED_ETH_DEFAULT) >= WLED_ETH_NONE) && ((WLED_ETH_DEFAULT) < WLED_NUM_ETH_TYPES), "WLED_ETH_DEFAULT is out of range."); +#endif + bool initEthernet() { static bool successfullyConfiguredEthernet = false;