mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
[light] Drop redundant is_standard_layout asserts (offsetof no longer used)
Since validate_() now accesses unit_fields_[] directly via the union alias, there's no offsetof arithmetic to guard. The FieldFlags bit layout assert is all that's needed.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include <cinttypes>
|
||||
#include <type_traits>
|
||||
|
||||
#include "light_call.h"
|
||||
#include "light_state.h"
|
||||
@@ -281,10 +280,7 @@ LightColorValues LightCall::validate_() {
|
||||
if (this->has_state())
|
||||
v.set_state(this->state_);
|
||||
|
||||
// FieldFlags bits 0-7 must match unit_fields_ array indices; the union in
|
||||
// both structs guarantees brightness_..warm_white_ alias unit_fields_[0..7].
|
||||
static_assert(std::is_standard_layout_v<LightCall>, "LightCall must be standard-layout");
|
||||
static_assert(std::is_standard_layout_v<LightColorValues>, "LightColorValues must be standard-layout");
|
||||
// FieldFlags bits 0-7 must match unit_fields_ array indices.
|
||||
static_assert(FLAG_HAS_BRIGHTNESS == 1u << 0 && FLAG_HAS_COLOR_BRIGHTNESS == 1u << 1 && FLAG_HAS_RED == 1u << 2 &&
|
||||
FLAG_HAS_GREEN == 1u << 3 && FLAG_HAS_BLUE == 1u << 4 && FLAG_HAS_WHITE == 1u << 5 &&
|
||||
FLAG_HAS_COLD_WHITE == 1u << 6 && FLAG_HAS_WARM_WHITE == 1u << 7,
|
||||
|
||||
Reference in New Issue
Block a user