bot comments

This commit is contained in:
J. Nick Koston
2026-04-09 08:10:39 -10:00
parent a0b0238ff8
commit c945cbc64c
2 changed files with 6 additions and 7 deletions
+3 -2
View File
@@ -352,8 +352,9 @@ std::string format_mac_address_pretty(const uint8_t *mac) {
// one is overwritten with '\0', eliminating the per-byte `i < length - 1` check.
static char *format_hex_internal(char *buffer, size_t buffer_size, const uint8_t *data, size_t length, char separator,
char base) {
if (length == 0) {
buffer[0] = '\0';
if (length == 0 || buffer_size == 0) {
if (buffer_size > 0)
buffer[0] = '\0';
return buffer;
}
uint8_t stride = separator ? 3 : 2;
+3 -5
View File
@@ -1263,15 +1263,13 @@ constexpr uint8_t parse_hex_char(char c) {
}
/// Convert a nibble (0-15) to hex char with specified base ('a' for lowercase, 'A' for uppercase)
__attribute__((always_inline)) inline char format_hex_char(uint8_t v, char base) {
return v >= 10 ? base + (v - 10) : '0' + v;
}
ESPHOME_ALWAYS_INLINE inline char format_hex_char(uint8_t v, char base) { return v >= 10 ? base + (v - 10) : '0' + v; }
/// Convert a nibble (0-15) to lowercase hex char
__attribute__((always_inline)) inline char format_hex_char(uint8_t v) { return format_hex_char(v, 'a'); }
ESPHOME_ALWAYS_INLINE inline char format_hex_char(uint8_t v) { return format_hex_char(v, 'a'); }
/// Convert a nibble (0-15) to uppercase hex char (used for pretty printing)
__attribute__((always_inline)) inline char format_hex_pretty_char(uint8_t v) { return format_hex_char(v, 'A'); }
ESPHOME_ALWAYS_INLINE inline char format_hex_pretty_char(uint8_t v) { return format_hex_char(v, 'A'); }
/// Write int8 value to buffer without modulo operations.
/// Buffer must have at least 4 bytes free. Returns pointer past last char written.