Skip to content

Commit

Permalink
cpu/esp: Handle format print errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Teufelchen1 committed Apr 25, 2024
1 parent 3c3c5c2 commit 01e78ed
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cpu/esp_common/lib_printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ static int _lib_printf(int level, const char* tag, const char* format, va_list a

int len = vsnprintf(_printf_buf, PRINTF_BUFSIZ - 1, format, arg);

if (len < 0) {
ESP_EARLY_LOGI(tag, "Failed to format print");
return 0;
}

/* Did the output get truncated? */
if ((unsigned) len > PRINTF_BUFSIZ - 1) {
len = PRINTF_BUFSIZ - 1;
}

/*
* Since ESP_EARLY_LOG macros add a line break at the end, a terminating
* line break in the output must be removed if there is one.
Expand Down

0 comments on commit 01e78ed

Please sign in to comment.