diff --git a/esphome/components/api/proto.cpp b/esphome/components/api/proto.cpp index e35565dd6d..8959ac7a2a 100644 --- a/esphome/components/api/proto.cpp +++ b/esphome/components/api/proto.cpp @@ -69,7 +69,7 @@ uint32_t ProtoDecodableMessage::count_repeated_field(const uint8_t *buffer, size break; // Invalid data, stop counting } - uint32_t tag = res.value; + uint32_t tag = static_cast(res.value); uint32_t field_type = tag & WIRE_TYPE_MASK; uint32_t field_id = tag >> 3; ptr += res.consumed; @@ -94,7 +94,7 @@ uint32_t ProtoDecodableMessage::count_repeated_field(const uint8_t *buffer, size if (!res.has_value()) { return count; } - uint32_t field_length = res.value; + uint32_t field_length = static_cast(res.value); ptr += res.consumed; if (field_length > static_cast(end - ptr)) { return count; // Out of bounds @@ -215,7 +215,7 @@ void ProtoDecodableMessage::decode(const uint8_t *buffer, size_t length) { return; } - uint32_t tag = res.value; + uint32_t tag = static_cast(res.value); uint32_t field_type = tag & WIRE_TYPE_MASK; uint32_t field_id = tag >> 3; ptr += res.consumed; @@ -240,7 +240,7 @@ void ProtoDecodableMessage::decode(const uint8_t *buffer, size_t length) { ESP_LOGV(TAG, "Invalid Length Delimited at offset %ld", (long) (ptr - buffer)); return; } - uint32_t field_length = res.value; + uint32_t field_length = static_cast(res.value); ptr += res.consumed; if (field_length > static_cast(end - ptr)) { ESP_LOGV(TAG, "Out-of-bounds Length Delimited at offset %ld", (long) (ptr - buffer));