mirror of
https://github.com/esphome/esphome.git
synced 2026-09-14 08:38:39 +00:00
bot comments
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user