From b4c5cdd52593f9211c849f180cf44d2b6afdce06 Mon Sep 17 00:00:00 2001 From: roderico <225260804+oroderico@users.noreply.github.com> Date: Fri, 18 Sep 2026 19:11:59 -0400 Subject: [PATCH] mnemonic: fix %zu format specifier in restore-flow titles snprintf() titles for the mnemonic restore flow (word selection, confirmation, insertion, and word-number restore) used %zu for size_t arguments. On at least ESP32-S3 boards this renders the raw "zu" characters instead of the value (e.g. "Word zu/zu"), observed on a Waveshare S3 Touch LCD2. Cast to unsigned int and use %u instead, which is unambiguous on this 32-bit target. --- main/process/mnemonic.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main/process/mnemonic.c b/main/process/mnemonic.c index 17f93dcf..f2d09d86 100644 --- a/main/process/mnemonic.c +++ b/main/process/mnemonic.c @@ -710,7 +710,8 @@ static wordlist_word_result_t select_wordlist_word(const bool is_mnemonic, const if (possible_words <= NUM_WORDS_SELECT) { // 'Small' number of words - allow user to select from these words char choose_word_title[16]; // sufficient - const int ret = snprintf(choose_word_title, sizeof(choose_word_title), "Select word %zu", word_index + 1); + const unsigned int word_num = word_index + 1; + const int ret = snprintf(choose_word_title, sizeof(choose_word_title), "Select word %u", word_num); JADE_ASSERT(ret > 0 && ret < sizeof(choose_word_title)); gui_update_text(ui->label, choose_word_title); @@ -849,7 +850,8 @@ static wordlist_word_result_t select_resolved_word_number(const size_t word_inde JADE_ASSERT(word && choose_word_activity && label && text_selection); char confirm_word_title[16]; // sufficient - const int ret = snprintf(confirm_word_title, sizeof(confirm_word_title), "Confirm word %zu", word_index + 1); + const unsigned int word_num = word_index + 1; + const int ret = snprintf(confirm_word_title, sizeof(confirm_word_title), "Confirm word %u", word_num); JADE_ASSERT(ret > 0 && ret < sizeof(confirm_word_title)); gui_update_text(label, confirm_word_title); @@ -935,7 +937,8 @@ static size_t get_wordlist_words( // Reset default title for next word when entering mnemonic phrase if (is_mnemonic) { char enter_word_title[16]; - const int ret = snprintf(enter_word_title, sizeof(enter_word_title), "Insert word %zu", word_index + 1); + const unsigned int word_num = word_index + 1; + const int ret = snprintf(enter_word_title, sizeof(enter_word_title), "Insert word %u", word_num); JADE_ASSERT(ret > 0 && ret < sizeof(enter_word_title)); gui_update_text(ui.titletext, enter_word_title); } @@ -1035,7 +1038,8 @@ static size_t get_word_number_words( JADE_ASSERT(!wordlist_words[word_index]); char title[24]; - const int ret = snprintf(title, sizeof(title), "Word %zu/%zu", word_index + 1, nwords); + const unsigned int word_num = word_index + 1; + const int ret = snprintf(title, sizeof(title), "Word %u/%u", word_num, (unsigned int)nwords); JADE_ASSERT(ret > 0 && ret < sizeof(title)); const char* word = NULL; @@ -1049,7 +1053,7 @@ static size_t get_word_number_words( = calculate_valid_final_words(wordlist_words, word_index, nwords, final_words); char enter_word_title[16]; - const int ret = snprintf(enter_word_title, sizeof(enter_word_title), "Insert word %zu", word_index + 1); + const int ret = snprintf(enter_word_title, sizeof(enter_word_title), "Insert word %u", word_num); JADE_ASSERT(ret > 0 && ret < sizeof(enter_word_title)); gui_update_text(calc_ui.titletext, enter_word_title);