cleanup ifdefs and typos

This commit is contained in:
J. Nick Koston
2026-02-11 08:34:17 -06:00
parent 94471be18b
commit 1050d083b4
4 changed files with 14 additions and 10 deletions

View File

@@ -125,7 +125,7 @@ void HOT Logger::log_vprintf_(uint8_t level, const char *tag, int line, const ch
// Other single-task platforms don't have thread names, so pass nullptr
this->log_message_to_buffer_and_send_(global_recursion_guard_, level, tag, line, format, args, nullptr);
}
#endif // USE_ESPHOME_TASK_LOG_BUFFER
#endif // USE_ESP32 || USE_HOST || USE_LIBRETINY || USE_ZEPHYR
#ifdef USE_STORE_LOG_STR_IN_FLASH
// Implementation for ESP8266 with flash string support.

View File

@@ -228,7 +228,9 @@ class Logger : public Component {
void log_vprintf_non_main_thread_(uint8_t level, const char *tag, int line, const char *format, va_list args,
const char *thread_name);
#endif
#if defined(USE_ZEPHYR) && defined(USE_LOGGER_USB_CDC)
void cdc_loop_();
#endif
void process_messages_();
void write_msg_(const char *msg, uint16_t len);

View File

@@ -47,7 +47,7 @@ bool TaskLogBuffer::send_message_thread_safe(uint8_t level, const char *tag, uin
size_t text_length = (static_cast<size_t>(ret) > MAX_TEXT_SIZE) ? MAX_TEXT_SIZE : ret;
size_t total_size = total_size_in_32bit_words(text_length);
auto *msg = reinterpret_cast<LogMessage *>(mpsc_pbuf_alloc(&this->log_buffer_, total_size, K_NO_WAIT));
if (nullptr == msg) {
if (msg == nullptr) {
return false;
}
msg->level = level;
@@ -63,7 +63,7 @@ bool TaskLogBuffer::send_message_thread_safe(uint8_t level, const char *tag, uin
// Handle unexpected formatting error
if (ret <= 0) {
// this shall not happened vsnprintf was called already once
// this should not happen, vsnprintf was called already once
// fill with '\n' to not call mpsc_pbuf_free from producer
// it will be trimmed anyway
for (size_t i = 0; i < text_length; ++i) {
@@ -86,11 +86,11 @@ bool TaskLogBuffer::borrow_message_main_loop(LogMessage *&message, uint16_t &tex
this->current_token_ = mpsc_pbuf_claim(&this->log_buffer_);
if (nullptr == this->current_token_) {
if (this->current_token_ == nullptr) {
return false;
}
// we claimed buffer alraedy const_cast is safe here
// we claimed buffer already, const_cast is safe here
message = const_cast<LogMessage *>(reinterpret_cast<const LogMessage *>(this->current_token_));
text_length = message->text_length;
@@ -109,6 +109,8 @@ void TaskLogBuffer::release_message_main_loop() {
mpsc_pbuf_free(&this->log_buffer_, this->current_token_);
this->current_token_ = nullptr;
}
#endif
#endif // USE_ESPHOME_TASK_LOG_BUFFER
} // namespace esphome::logger
#endif
#endif // USE_ZEPHYR

View File

@@ -19,7 +19,7 @@ class TaskLogBuffer {
public:
// Structure for a log message header (text data follows immediately after)
struct LogMessage {
MPSC_PBUF_HDR; // this is only 2 bits put not more that 30 bits directly after
MPSC_PBUF_HDR; // this is only 2 bits but no more than 30 bits directly after
uint16_t line; // Source code line number
uint8_t level; // Log level (0-7)
#if defined(CONFIG_THREAD_NAME)
@@ -59,8 +59,8 @@ class TaskLogBuffer {
const mpsc_pbuf_generic *current_token_{};
};
#endif
#endif // USE_ESPHOME_TASK_LOG_BUFFER
} // namespace esphome::logger
#endif
#endif // USE_ZEPHYR