From 972d0978bde1b519064e5d91f08678b095bec162 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 8 Mar 2026 21:04:55 -1000 Subject: [PATCH] [api] Add explicit static_cast in decode_zigzag32 calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On BLE builds where proto_varint_value_t is uint64_t, decode_zigzag32() takes uint32_t — make the narrowing explicit to match the static_cast pattern used for other type conversions in generated code. Co-Authored-By: Claude Opus 4.6 --- esphome/components/api/api_pb2.cpp | 10 +++++----- script/api_protobuf/api_protobuf.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index e69654067b6..a4324b8db3f 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -1039,7 +1039,7 @@ bool HomeAssistantStateResponse::decode_length(uint32_t field_id, ProtoLengthDel bool DSTRule::decode_varint(uint32_t field_id, proto_varint_value_t value) { switch (field_id) { case 1: - this->time_seconds = decode_zigzag32(value); + this->time_seconds = decode_zigzag32(static_cast(value)); break; case 2: this->day = value; @@ -1064,10 +1064,10 @@ bool DSTRule::decode_varint(uint32_t field_id, proto_varint_value_t value) { bool ParsedTimezone::decode_varint(uint32_t field_id, proto_varint_value_t value) { switch (field_id) { case 1: - this->std_offset_seconds = decode_zigzag32(value); + this->std_offset_seconds = decode_zigzag32(static_cast(value)); break; case 2: - this->dst_offset_seconds = decode_zigzag32(value); + this->dst_offset_seconds = decode_zigzag32(static_cast(value)); break; default: return false; @@ -1147,13 +1147,13 @@ bool ExecuteServiceArgument::decode_varint(uint32_t field_id, proto_varint_value this->legacy_int = static_cast(value); break; case 5: - this->int_ = decode_zigzag32(value); + this->int_ = decode_zigzag32(static_cast(value)); break; case 6: this->bool_array.push_back(value != 0); break; case 7: - this->int_array.push_back(decode_zigzag32(value)); + this->int_array.push_back(decode_zigzag32(static_cast(value))); break; default: return false; diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index 1c2a3e5cc2f..b4044c362c6 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -1262,7 +1262,7 @@ class SFixed64Type(TypeInfo): class SInt32Type(TypeInfo): cpp_type = "int32_t" default_value = "0" - decode_varint = "decode_zigzag32(value)" + decode_varint = "decode_zigzag32(static_cast(value))" encode_func = "encode_sint32" wire_type = WireType.VARINT # Uses wire type 0