mnemonic: avoid an unused variable warning for ci builds
What changed, and why it matters
This commit is a minor code cleanup in a hardware wallet firmware project. It rearranges existing conditional code so that a compiler warning about an unused variable is avoided in automated CI builds. The actual behavior—using a hardcoded test recovery phrase only in special debug CI builds—was already present before this change. There is no new security-relevant behavior introduced.
No security action required. Treat as normal maintenance. If reviewing broader security posture, verify that CONFIG_DEBUG_UNATTENDED_CI is never enabled in production/release builds and that CI artifacts are clearly marked/debug-only.
Security signals we found
Hardcoded mnemonic exists, but is only compiled into debug unattended CI builds via CONFIG_DEBUG_UNATTENDED_CI
No new secret, key, or authentication material introduced
No change to production code paths or runtime behavior outside CI debug builds
Refactoring to suppress compiler warning, not to alter security logic
Evidence from the diff
The change refactors the handling of BTN_EVENT_TIMEOUT in initialise_with_mnemonic(). Previously, the entire switch statement was wrapped in #ifndef CONFIG_DEBUG_UNATTENDED_CI, and a separate #else branch handled the CI case outside the switch. This left ev_id unused in CI builds, triggering a warning. The patch moves the CI-specific hardcoded mnemonic assignment into the switch as a case under #ifdef CONFIG_DEBUG_UNATTENDED_CI, making ev_id used in all configurations. The hardcoded mnemonic is identical to the pre-existing one and remains gated by the same debug CI-only preprocessor flag.
Changed components
main/process/mnemonic.cinitialise_with_mnemonic()CONFIG_DEBUG_UNATTENDED_CI build pathInspect captured patch +11 / −10
diff --git a/main/process/mnemonic.c b/main/process/mnemonic.c
index c8d2575..5da418a 100644
--- a/main/process/mnemonic.c
+++ b/main/process/mnemonic.c
@@ -1334,9 +1334,18 @@ void initialise_with_mnemonic(const bool temporary_restore, const bool force_qr_
gui_set_current_activity_ex(act, true);
const int32_t ev_id = gui_activity_wait_button(act, BTN_EVENT_TIMEOUT);
-#ifndef CONFIG_DEBUG_UNATTENDED_CI
switch (ev_id) {
case BTN_EVENT_TIMEOUT:
+#ifdef CONFIG_DEBUG_UNATTENDED_CI
+ // In a debug unattended ci build, use hardcoded mnemonic after a short delay
+ strcpy(mnemonic,
+ "fish inner face ginger orchard permit useful method fence kidney chuckle party favorite sunset "
+ "draw "
+ "limb "
+ "science crane oval letter slot invite sadness banana");
+ got_mnemonic = true;
+ break;
+#else
JADE_ASSERT(false);
case BTN_MNEMONIC_EXIT:
// Abandon setting up mnemonic altogether
@@ -1391,19 +1400,11 @@ void initialise_with_mnemonic(const bool temporary_restore, const bool force_qr_
got_mnemonic = mnemonic_qr(mnemonic, sizeof(mnemonic));
qr_scanned = got_mnemonic;
break;
-
+#endif
default:
// Unknown event, ignore
continue;
}
-#else
- // In a debug unattended ci build, use hardcoded mnemonic after a short delay
- strcpy(mnemonic,
- "fish inner face ginger orchard permit useful method fence kidney chuckle party favorite sunset draw "
- "limb "
- "science crane oval letter slot invite sadness banana");
- got_mnemonic = true;
-#endif
}
}
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.