From 72ebee5267ad5bf633a1705de9890287bd644ab3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 16 Jan 2026 13:28:51 -1000 Subject: [PATCH 1/4] bot review --- esphome/components/mapping/mapping.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/esphome/components/mapping/mapping.h b/esphome/components/mapping/mapping.h index 92138c4377c..1e4f7858aae 100644 --- a/esphome/components/mapping/mapping.h +++ b/esphome/components/mapping/mapping.h @@ -45,16 +45,25 @@ template class Mapping { } else if constexpr (std::is_same_v) { esph_log_e(TAG, "Key '%s' not found in mapping", key.c_str()); } else if constexpr (std::is_integral_v) { - char buf[24]; // enough for int64_t - buf_append_printf(buf, sizeof(buf), 0, "%" PRId64, static_cast(key)); + char buf[24]; // enough for 64-bit integer + if constexpr (std::is_unsigned_v) { + buf_append_printf(buf, sizeof(buf), 0, "%" PRIu64, static_cast(key)); + } else { + buf_append_printf(buf, sizeof(buf), 0, "%" PRId64, static_cast(key)); + } esph_log_e(TAG, "Key '%s' not found in mapping", buf); } else if constexpr (std::is_floating_point_v) { - char buf[24]; + char buf[32]; // enough for %g with doubles buf_append_printf(buf, sizeof(buf), 0, "%g", static_cast(key)); esph_log_e(TAG, "Key '%s' not found in mapping", buf); } else if constexpr (std::is_enum_v) { + using underlying_t = std::underlying_type_t; char buf[24]; // enough for underlying integral type - buf_append_printf(buf, sizeof(buf), 0, "%" PRId64, static_cast(key)); + if constexpr (std::is_unsigned_v) { + buf_append_printf(buf, sizeof(buf), 0, "%" PRIu64, static_cast(static_cast(key))); + } else { + buf_append_printf(buf, sizeof(buf), 0, "%" PRId64, static_cast(static_cast(key))); + } esph_log_e(TAG, "Key '%s' not found in mapping", buf); } else { // Fallback for custom types - likely unreachable but kept for compatibility From 90989aa7cde817420f0c4a7104342fb23fecea9e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 16 Jan 2026 13:30:27 -1000 Subject: [PATCH 2/4] bot review --- esphome/components/mapping/mapping.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/mapping/mapping.h b/esphome/components/mapping/mapping.h index 1e4f7858aae..ef20a173b7b 100644 --- a/esphome/components/mapping/mapping.h +++ b/esphome/components/mapping/mapping.h @@ -66,8 +66,8 @@ template class Mapping { } esph_log_e(TAG, "Key '%s' not found in mapping", buf); } else { - // Fallback for custom types - likely unreachable but kept for compatibility - esph_log_e(TAG, "Key '%s' not found in mapping", to_string(key).c_str()); + // All supported key types are handled above - this should never be reached + static_assert(sizeof(K) == 0, "Unsupported key type for Mapping error logging"); } return {}; } From bdabbdaaea601aa1c6d6dadae4d91eeb21f61275 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 16 Jan 2026 13:31:30 -1000 Subject: [PATCH 3/4] bot review --- esphome/components/mapping/mapping.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/esphome/components/mapping/mapping.h b/esphome/components/mapping/mapping.h index ef20a173b7b..fd56b6c814e 100644 --- a/esphome/components/mapping/mapping.h +++ b/esphome/components/mapping/mapping.h @@ -56,15 +56,6 @@ template class Mapping { char buf[32]; // enough for %g with doubles buf_append_printf(buf, sizeof(buf), 0, "%g", static_cast(key)); esph_log_e(TAG, "Key '%s' not found in mapping", buf); - } else if constexpr (std::is_enum_v) { - using underlying_t = std::underlying_type_t; - char buf[24]; // enough for underlying integral type - if constexpr (std::is_unsigned_v) { - buf_append_printf(buf, sizeof(buf), 0, "%" PRIu64, static_cast(static_cast(key))); - } else { - buf_append_printf(buf, sizeof(buf), 0, "%" PRId64, static_cast(static_cast(key))); - } - esph_log_e(TAG, "Key '%s' not found in mapping", buf); } else { // All supported key types are handled above - this should never be reached static_assert(sizeof(K) == 0, "Unsupported key type for Mapping error logging"); From befe5d3bd2021c4d2a5fe2b8f16fcac40c84e9e3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 16 Jan 2026 13:32:31 -1000 Subject: [PATCH 4/4] bot review --- esphome/components/mapping/mapping.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/esphome/components/mapping/mapping.h b/esphome/components/mapping/mapping.h index fd56b6c814e..2b8f0d39b2a 100644 --- a/esphome/components/mapping/mapping.h +++ b/esphome/components/mapping/mapping.h @@ -52,10 +52,6 @@ template class Mapping { buf_append_printf(buf, sizeof(buf), 0, "%" PRId64, static_cast(key)); } esph_log_e(TAG, "Key '%s' not found in mapping", buf); - } else if constexpr (std::is_floating_point_v) { - char buf[32]; // enough for %g with doubles - buf_append_printf(buf, sizeof(buf), 0, "%g", static_cast(key)); - esph_log_e(TAG, "Key '%s' not found in mapping", buf); } else { // All supported key types are handled above - this should never be reached static_assert(sizeof(K) == 0, "Unsupported key type for Mapping error logging");