Skip to content

Commit

Permalink
Merge pull request #20596 from Teufelchen1/fix/esp_print
Browse files Browse the repository at this point in the history
cpu/esp: Handle format print errors
  • Loading branch information
Teufelchen1 authored Apr 25, 2024
2 parents 5409364 + 01e78ed commit 925644e
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 925644e

Please sign in to comment.