Skip to content

Conversation

@somebodyLi
Copy link
Contributor

@somebodyLi somebodyLi commented Dec 9, 2025

Summary by CodeRabbit

  • New Features

    • Added support for Hydration and Bifrost networks
    • Polkadot transactions can include an SS58 address-type prefix
  • Improvements

    • Enhanced address type detection and handling for Polkadot flows
    • Improved long-press navigation on hardware for transaction/detail browsing
    • Preserve safety-check level across soft resets
  • Localization

    • Updated Chinese translations for mnemonic entry clarity
  • Chores

    • Version bumped to 3.16.0

✏️ Tip: You can customize this high-level summary in your review settings.

@revan-zhang
Copy link
Contributor

revan-zhang commented Dec 9, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Walkthrough

Preserve safety-check level across soft resets, add long-press navigation support for several UI flows, refactor Polkadot address-type detection and parsing with new network metadata and asset fields, add Hydration/Bifrost network support, update Chinese locale strings, add protobuf prefix field, and bump firmware to 3.16.0.

Changes

Cohort / File(s) Summary
Protobuf schema
common/protob/messages-polkadot.proto
Added optional uint32 prefix = 4 to PolkadotSignTx for SS58 address-type.
Soft-reset preservation
legacy/util.h, legacy/firmware/startup.S, legacy/gd32_hard/memory_app_1.8.0_gd32.ld, legacy/memory_app_1.8.0.ld, legacy/firmware/usb.c, legacy/firmware/config.c
Introduced preserved-reset data symbol at 0x20010004, macros and inline APIs to set/get/clear preserved 16-bit payload (with emulator stubs), assembly save/restore across RAM clear, USB hook to store safety-check level on reset, and config initialization to restore preserved safety-check level.
Long-press navigation (UI input)
legacy/buttons.c, legacy/firmware/layout2.c, legacy/firmware/ethereum_onekey.c, legacy/firmware/ethereum_typed_data.h, legacy/firmware/recovery.c, legacy/firmware/protect.h
Added long-press enable/disable stubs for emulator and conditional non-emulator handling. Enabled long-press UP/DOWN mapping to KEY_UP/KEY_DOWN with brief debounce in Ethereum signing, typed-data, layout details, and recovery flows. Ensure long-press disabled on abort paths.
Polkadot parser & tx parsing
legacy/firmware/polkadot.c, legacy/firmware/polkadot/tx.c, legacy/firmware/polkadot/tx.h, legacy/firmware/polkadot/parser.c, legacy/firmware/polkadot/parser_impl_common.c, legacy/firmware/polkadot/parser_impl.c, legacy/firmware/polkadot/parser_common.h, legacy/firmware/polkadot/parser_impl.h, legacy/firmware/polkadot/parser_txdef.h
Refactored address-type API: added getAddressType()/setAddressType() and detectNetworkMetadata() (replacing old private functions). Added has_preset_address_type and preset_address_type to parser context and propagated new has_preset_address_type, preset_address_type params into polkadot_tx_parse. Added assetId and assetLocation fields and guarded asset reads by remaining buffer length.
Substrate / network support
legacy/firmware/polkadot/substrate/substrate_coin.h, legacy/firmware/polkadot/substrate/substrate_dispatch_V26.c, legacy/firmware/polkadot/substrate/substrate_types.c
Added BIFROST_COIN_TICKER and HYDRATION_COIN_TICKER. Extended dispatch switch-cases and helper functions to include Hydration module indices alongside Manta. Broadened network name checks to include hydration.
Localization & tooling
legacy/firmware/i18n/locales/zh_cn.inc, legacy/firmware/i18n/locales/zh_tw.inc, legacy/script/i18n.py
Updated Chinese locale strings to include a space and the character 位 for word-count phrasing. Set replace_breaks: 1 in Lokalise retrieval.
Version bump
legacy/firmware/version.h
Bumped ONEKEY_VER_MINOR from 15→16 and ONEKEY_VERSION from "3.15.0"→"3.16.0"; added ONEKEY_VERSION_HEX macro.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Areas needing careful review:

  • Polkadot parser refactor: address-type API changes (detectNetworkMetadata, getAddressType, setAddressType), parser context fields, and polkadot_tx_parse signature propagation.
  • Asset parsing guard in _polkadot_readTx: verify length-based condition and compatibility with upstream formats.
  • Soft-reset preservation: linker symbol placement, assembly save/restore, and correct restore timing in config_init.
  • Long-press integration: ensure preprocessor guards exclude emulator builds and abort paths disable long-press cleanly.
  • Dispatch and network additions: consistent mapping of hydration/bifrost cases across helper functions and UI descriptors.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the primary change—adapting legacy firmware for Polkadot updates. It's clear, concise, and specific enough for scanning PR history.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 3.16.0

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c91cbb0 and 15302f6.

📒 Files selected for processing (17)
  • legacy/buttons.c (1 hunks)
  • legacy/firmware/config.c (1 hunks)
  • legacy/firmware/ethereum_onekey.c (9 hunks)
  • legacy/firmware/ethereum_typed_data.h (3 hunks)
  • legacy/firmware/i18n/locales/zh_cn.inc (1 hunks)
  • legacy/firmware/i18n/locales/zh_tw.inc (1 hunks)
  • legacy/firmware/layout2.c (3 hunks)
  • legacy/firmware/polkadot.c (1 hunks)
  • legacy/firmware/protect.h (1 hunks)
  • legacy/firmware/recovery.c (4 hunks)
  • legacy/firmware/startup.S (1 hunks)
  • legacy/firmware/usb.c (1 hunks)
  • legacy/firmware/version.h (1 hunks)
  • legacy/gd32_hard/memory_app_1.8.0_gd32.ld (1 hunks)
  • legacy/memory_app_1.8.0.ld (1 hunks)
  • legacy/script/i18n.py (1 hunks)
  • legacy/util.h (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
legacy/firmware/usb.c (3)
legacy/util.h (2)
  • soft_reset_set_preserved_data (156-160)
  • soft_reset_set_preserved_data (178-178)
legacy/firmware/config.c (1)
  • config_getSafetyCheckLevel (683-683)
legacy/firmware/config_emu.c (1)
  • config_getSafetyCheckLevel (1366-1366)
legacy/firmware/polkadot.c (2)
legacy/firmware/polkadot/parser_impl_common.c (1)
  • getAddressType (341-341)
legacy/firmware/polkadot/tx.c (1)
  • polkadot_tx_parse (9-25)
legacy/firmware/layout2.c (2)
legacy/buttons.c (6)
  • enableLongPress (91-91)
  • enableLongPress (204-204)
  • isLongPress (95-100)
  • isLongPress (206-206)
  • getLongPressStatus (93-93)
  • getLongPressStatus (205-205)
legacy/timer.c (1)
  • delay_ms (38-43)
legacy/firmware/ethereum_typed_data.h (1)
legacy/buttons.c (6)
  • enableLongPress (91-91)
  • enableLongPress (204-204)
  • isLongPress (95-100)
  • isLongPress (206-206)
  • getLongPressStatus (93-93)
  • getLongPressStatus (205-205)
legacy/firmware/config.c (1)
legacy/util.h (4)
  • soft_reset_get_preserved_data (162-168)
  • soft_reset_get_preserved_data (179-179)
  • soft_reset_clear_preserved_data (170-172)
  • soft_reset_clear_preserved_data (180-180)
legacy/firmware/ethereum_onekey.c (1)
legacy/buttons.c (6)
  • enableLongPress (91-91)
  • enableLongPress (204-204)
  • isLongPress (95-100)
  • isLongPress (206-206)
  • getLongPressStatus (93-93)
  • getLongPressStatus (205-205)
🪛 Clang (14.0.6)
legacy/firmware/polkadot.c

[warning] 136-136: parameter 'msg' is unused

(misc-unused-parameters)


[warning] 137-137: parameter 'resp' is unused

(misc-unused-parameters)


[warning] 140-140: variable 'ret' is not initialized

(cppcoreguidelines-init-variables)


[warning] 143-143: 64 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)

legacy/firmware/layout2.c

[note] 4428-4428: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 4429-4429: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[note] 4431-4431: +1, nesting level increased to 4

(clang)


[warning] 4429-4429: repeated branch in conditional chain

(bugprone-branch-clone)


[note] 4431-4431: end of the original

(clang)


[note] 4431-4431: clone 1 starts here

(clang)

legacy/firmware/ethereum_typed_data.h

[note] 1089-1089: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 1090-1090: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[note] 1092-1092: +1, nesting level increased to 4

(clang)


[warning] 1090-1090: repeated branch in conditional chain

(bugprone-branch-clone)


[note] 1092-1092: end of the original

(clang)


[note] 1092-1092: clone 1 starts here

(clang)

legacy/util.h

[warning] 99-99: declaration uses identifier '_preserved_reset_data_addr', which is reserved in the global namespace

(bugprone-reserved-identifier)


[warning] 99-99: variable '_preserved_reset_data_addr' is non-const and globally accessible, consider making it const

(cppcoreguidelines-avoid-non-const-global-variables)

legacy/firmware/ethereum_onekey.c

[note] 656-656: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 657-657: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[note] 659-659: +1, nesting level increased to 4

(clang)


[warning] 657-657: repeated branch in conditional chain

(bugprone-branch-clone)


[note] 659-659: end of the original

(clang)


[note] 659-659: clone 1 starts here

(clang)


[note] 737-737: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 738-738: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[note] 740-740: +1, nesting level increased to 4

(clang)


[warning] 738-738: repeated branch in conditional chain

(bugprone-branch-clone)


[note] 740-740: end of the original

(clang)


[note] 740-740: clone 1 starts here

(clang)


[note] 935-935: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 936-936: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[note] 938-938: +1, nesting level increased to 4

(clang)


[warning] 936-936: repeated branch in conditional chain

(bugprone-branch-clone)


[note] 938-938: end of the original

(clang)


[note] 938-938: clone 1 starts here

(clang)

legacy/firmware/recovery.c

[note] 818-818: +1, including nesting penalty of 0, nesting level increased to 1

(clang)

🪛 Cppcheck (2.18.0)
legacy/firmware/usb.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

legacy/firmware/polkadot.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[style] 141-141: The function 'bn_copy' is never used.

(unusedFunction)


[style] 144-144: The function 'bn_is_even' is never used.

(unusedFunction)


[style] 136-136: The function 'polkadot_sign_tx' is never used.

(unusedFunction)

legacy/firmware/layout2.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

legacy/buttons.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[style] 204-204: The function 'enableLongPress' is never used.

(unusedFunction)


[style] 205-205: The function 'getLongPressStatus' is never used.

(unusedFunction)


[style] 206-206: The function 'isLongPress' is never used.

(unusedFunction)

legacy/firmware/config.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[style] 274-274: The function 'oledClear_ext' is never used.

(unusedFunction)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

legacy/firmware/ethereum_onekey.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[error] 655-655: Using pointer to local variable 'temp_field_name' that is out of scope.

(invalidLifetime)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)

legacy/firmware/recovery.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)

🔇 Additional comments (11)
legacy/firmware/version.h (1)

9-13: Version bump looks correct.

The numeric macros and string are consistent at 3.16.0.

legacy/firmware/polkadot.c (1)

134-134: Extern now at file scope—good fix.

This addresses the earlier feedback. Placing it near other externs at the top of the file would be slightly cleaner, but this works.

legacy/script/i18n.py (1)

177-179: Remove the invalid replace_breaks parameter from the keys() API call.

The replace_breaks parameter is not supported by the keys() method and will be silently ignored. This parameter only applies to the FILES API for upload/download operations. Line break handling in translations is already managed correctly by the Python code at line 16 via .replace("\\n", " "), which converts escaped newlines to spaces.

Likely an incorrect or invalid review comment.

legacy/firmware/usb.c (1)

524-543: SafetyCheckLevel preservation across soft reset is wired correctly

Storing config_getSafetyCheckLevel() into preserved reset data immediately after session_clear(true) ensures the safety-check level survives this soft reset and can be restored in config_init, without affecting normal state because session_clear doesn’t touch that field. Using a 16‑bit payload matches the preserved‑data helper.

legacy/gd32_hard/memory_app_1.8.0_gd32.ld (1)

50-52: Linker symbol for preserved reset data looks consistent

Defining _preserved_reset_data_addr at 0x20010004 next to _stay_in_bootloader_flag_addr matches the preserved‑data mechanism in util.h and startup.S. This gives a dedicated word for soft‑reset state without touching the stack or heap layout.

legacy/firmware/startup.S (1)

54-66: Preserving reset data via r11 across SRAM clear is ABI‑safe

Loading *_preserved_reset_data_addr into r11 before memset_reg and writing it back afterward correctly keeps that word alive through the full RAM clear. r11 is callee‑saved, so memset_reg and later C calls shouldn’t overwrite it, but avoid reusing r11 for other purposes in reset_handler before the store at Line 65.

legacy/firmware/config.c (1)

272-280: Soft‑reset restore of SafetyCheckLevel is scoped to the temporary mode

Restoring safetyCheckLevel only when the preserved value equals SafetyCheckLevel_PromptTemporarily, then immediately calling soft_reset_clear_preserved_data(), lets the “prompt temporarily” choice survive a soft reset but still behave as ephemeral state. This runs early in config_init, before other config reads, which is the right place.

legacy/buttons.c (1)

202-206: Emulator long‑press stubs keep the API safe to call

These no‑op implementations of enableLongPress, getLongPressStatus, and isLongPress make emulator builds link cleanly while ensuring long‑press checks always behave as “disabled” there. This matches how the callers guard real behavior with #if !EMULATOR.

legacy/firmware/layout2.c (1)

4389-4453: SafeTx details long‑press handling looks solid

You scope enableLongPress(true/false) tightly around the details loop and map UP/DOWN long‑presses to KEY_UP/KEY_DOWN with a small delay, matching the pattern used in other flows. No stray paths leave long‑press enabled, and emulator behavior stays unchanged.

legacy/memory_app_1.8.0.ld (1)

27-31: Preserved‑reset data slot is well‑placed

The new _preserved_reset_data_addr at 0x20010004 cleanly follows the bootloader flag word and stays inside the RAM region. It aligns with the uint32_t access pattern in util.h and doesn’t clash with the stack/guard words at the top of RAM.

legacy/firmware/recovery.c (1)

658-705: select_complete_word refactor keeps behavior and isolates long‑press

Using a local ret and returning at the end preserves the old semantics (only CONFIRM yields true). Disabling long‑press on entry and restoring it on exit keeps this sub‑menu from inheriting the outer long‑press behavior, which is a clean separation.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 14

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e29497b and c91cbb0.

📒 Files selected for processing (27)
  • common/protob/messages-polkadot.proto (1 hunks)
  • legacy/firmware/config.c (1 hunks)
  • legacy/firmware/ethereum_onekey.c (9 hunks)
  • legacy/firmware/ethereum_typed_data.h (3 hunks)
  • legacy/firmware/i18n/locales/zh_cn.inc (1 hunks)
  • legacy/firmware/i18n/locales/zh_tw.inc (1 hunks)
  • legacy/firmware/layout2.c (3 hunks)
  • legacy/firmware/polkadot.c (1 hunks)
  • legacy/firmware/polkadot/parser.c (1 hunks)
  • legacy/firmware/polkadot/parser_common.h (1 hunks)
  • legacy/firmware/polkadot/parser_impl.c (1 hunks)
  • legacy/firmware/polkadot/parser_impl.h (1 hunks)
  • legacy/firmware/polkadot/parser_impl_common.c (1 hunks)
  • legacy/firmware/polkadot/parser_txdef.h (2 hunks)
  • legacy/firmware/polkadot/substrate/substrate_coin.h (1 hunks)
  • legacy/firmware/polkadot/substrate/substrate_dispatch_V26.c (13 hunks)
  • legacy/firmware/polkadot/substrate/substrate_types.c (1 hunks)
  • legacy/firmware/polkadot/tx.c (1 hunks)
  • legacy/firmware/polkadot/tx.h (2 hunks)
  • legacy/firmware/recovery.c (4 hunks)
  • legacy/firmware/startup.S (1 hunks)
  • legacy/firmware/usb.c (1 hunks)
  • legacy/firmware/version.h (1 hunks)
  • legacy/gd32_hard/memory_app_1.8.0_gd32.ld (1 hunks)
  • legacy/memory_app_1.8.0.ld (1 hunks)
  • legacy/script/i18n.py (1 hunks)
  • legacy/util.h (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (12)
legacy/firmware/usb.c (3)
legacy/util.h (2)
  • soft_reset_set_preserved_data (156-160)
  • soft_reset_set_preserved_data (178-178)
legacy/firmware/config.c (1)
  • config_getSafetyCheckLevel (683-683)
legacy/firmware/config_emu.c (1)
  • config_getSafetyCheckLevel (1366-1366)
legacy/firmware/ethereum_onekey.c (1)
legacy/buttons.c (3)
  • enableLongPress (91-91)
  • isLongPress (95-100)
  • getLongPressStatus (93-93)
legacy/firmware/polkadot/parser_impl.c (1)
legacy/firmware/polkadot/substrate/substrate_types.c (1)
  • _readu8 (18-20)
legacy/util.h (1)
tests/ui_tests/reporting/testreport.js (1)
  • value (66-66)
legacy/firmware/layout2.c (2)
legacy/buttons.c (3)
  • enableLongPress (91-91)
  • isLongPress (95-100)
  • getLongPressStatus (93-93)
legacy/timer.c (1)
  • delay_ms (38-43)
legacy/firmware/polkadot.c (2)
legacy/firmware/polkadot/parser_impl_common.c (1)
  • getAddressType (341-341)
legacy/firmware/polkadot/tx.c (1)
  • polkadot_tx_parse (9-25)
legacy/firmware/polkadot/parser.c (1)
legacy/firmware/polkadot/parser_impl_common.c (2)
  • detectNetworkMetadata (344-386)
  • setAddressType (342-342)
legacy/firmware/polkadot/tx.h (1)
legacy/firmware/polkadot/tx.c (1)
  • polkadot_tx_parse (9-25)
legacy/firmware/recovery.c (1)
legacy/buttons.c (1)
  • isLongPress (95-100)
legacy/firmware/ethereum_typed_data.h (1)
legacy/buttons.c (3)
  • enableLongPress (91-91)
  • isLongPress (95-100)
  • getLongPressStatus (93-93)
legacy/firmware/polkadot/parser_impl.h (1)
legacy/firmware/polkadot/parser_impl_common.c (4)
  • getAddressType (341-341)
  • setAddressType (342-342)
  • _readCompactIndex (211-215)
  • detectNetworkMetadata (344-386)
legacy/firmware/config.c (1)
legacy/util.h (4)
  • soft_reset_get_preserved_data (162-168)
  • soft_reset_get_preserved_data (179-179)
  • soft_reset_clear_preserved_data (170-172)
  • soft_reset_clear_preserved_data (180-180)
🪛 Clang (14.0.6)
legacy/firmware/ethereum_onekey.c

[note] 656-656: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 657-657: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[note] 659-659: +1, nesting level increased to 4

(clang)


[warning] 657-657: repeated branch in conditional chain

(bugprone-branch-clone)


[note] 659-659: end of the original

(clang)


[note] 659-659: clone 1 starts here

(clang)


[note] 737-737: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 738-738: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[note] 740-740: +1, nesting level increased to 4

(clang)


[warning] 738-738: repeated branch in conditional chain

(bugprone-branch-clone)


[note] 740-740: end of the original

(clang)


[note] 740-740: clone 1 starts here

(clang)


[note] 935-935: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 936-936: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[note] 938-938: +1, nesting level increased to 4

(clang)


[warning] 936-936: repeated branch in conditional chain

(bugprone-branch-clone)


[note] 938-938: end of the original

(clang)


[note] 938-938: clone 1 starts here

(clang)

legacy/firmware/polkadot/tx.c

[warning] 9-9: parameter 'data' is unused

(misc-unused-parameters)


[warning] 9-9: 3 adjacent parameters of 'polkadot_tx_parse' of similar type ('int') are easily swapped by mistake

(bugprone-easily-swappable-parameters)


[note] 9-9: the first parameter in the range is 'dataLen'

(clang)


[note] 11-11: the last parameter in the range is 'preset_address_type'

(clang)


[warning] 9-9: parameter 'dataLen' is unused

(misc-unused-parameters)


[warning] 10-10: parameter 'has_preset_address_type' is unused

(misc-unused-parameters)


[warning] 11-11: parameter 'preset_address_type' is unused

(misc-unused-parameters)

legacy/firmware/polkadot/parser_impl.c

[note] 22-22: +2, including nesting penalty of 1, nesting level increased to 2

(clang)


[note] 24-24: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 25-25: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 26-26: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[note] 27-27: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[warning] 23-23: 74 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)

legacy/util.h

[warning] 99-99: declaration uses identifier '_preserved_reset_data_addr', which is reserved in the global namespace

(bugprone-reserved-identifier)


[warning] 99-99: variable '_preserved_reset_data_addr' is non-const and globally accessible, consider making it const

(cppcoreguidelines-avoid-non-const-global-variables)

legacy/firmware/layout2.c

[note] 4428-4428: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 4429-4429: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[note] 4431-4431: +1, nesting level increased to 4

(clang)


[warning] 4429-4429: repeated branch in conditional chain

(bugprone-branch-clone)


[note] 4431-4431: end of the original

(clang)


[note] 4431-4431: clone 1 starts here

(clang)

legacy/firmware/polkadot.c

[warning] 134-134: parameter 'msg' is unused

(misc-unused-parameters)


[warning] 135-135: parameter 'resp' is unused

(misc-unused-parameters)


[warning] 138-138: variable 'ret' is not initialized

(cppcoreguidelines-init-variables)


[warning] 141-141: 64 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)

legacy/firmware/polkadot/substrate/substrate_dispatch_V26.c

[warning] 45-45: 1792 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 46-46: 2560 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 48-48: 7936 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 49-49: 7943 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 53-53: 1026 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 54-54: 1282 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 55-55: 1794 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 56-56: 2562 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 58-58: 7938 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 62-62: 1027 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 63-63: 1283 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 64-64: 1795 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 65-65: 2563 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 67-67: 7939 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 71-71: 1028 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 72-72: 1284 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 73-73: 1796 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 74-74: 2564 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 92-92: 7 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 93-93: 10 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 111-111: 1792 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 112-112: 2560 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 113-113: 7936 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 114-114: 7943 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 116-116: 1026 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 117-117: 1282 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 118-118: 1794 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 119-119: 2562 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 120-120: 7938 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 122-122: 1027 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 123-123: 1283 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 124-124: 1795 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 125-125: 2563 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 126-126: 7939 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 128-128: 1028 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 129-129: 1284 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 130-130: 1796 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 148-148: 1792 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 149-149: 2560 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 150-150: 7936 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 151-151: 7943 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 153-153: 1026 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 154-154: 1282 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 155-155: 1794 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 156-156: 2562 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 157-157: 7938 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 159-159: switch has 2 consecutive identical branches

(bugprone-branch-clone)


[warning] 159-159: 1027 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 160-160: 1283 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 161-161: 1795 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 162-162: 2563 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 163-163: 7939 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 165-165: 1028 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 166-166: 1284 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 167-167: 1796 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 186-186: 1792 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 199-199: 1794 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 213-213: 1795 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 225-225: 1796 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 250-250: 1792 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 269-269: 1794 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 291-291: 1795 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 309-309: 1796 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 344-344: 1792 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 345-345: 2560 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 346-346: 7936 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 347-347: 7943 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 348-348: 1026 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 349-349: 1282 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 350-350: 1794 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 351-351: 2562 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 352-352: 7938 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 353-353: 1027 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 354-354: 1283 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 355-355: 1795 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 356-356: 2563 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 357-357: 7939 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 358-358: 1028 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 359-359: 1284 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 360-360: 1796 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)

legacy/firmware/polkadot/parser.c

[warning] 46-46: if with identical then and else branches

(bugprone-branch-clone)


[note] 48-48: else branch starts here

(clang)

legacy/firmware/recovery.c

[note] 813-813: +1, nesting level increased to 2

(clang)


[note] 813-813: end of the original

(clang)


[note] 813-813: clone 1 starts here

(clang)

legacy/firmware/ethereum_typed_data.h

[note] 1089-1089: +3, including nesting penalty of 2, nesting level increased to 3

(clang)


[note] 1090-1090: +4, including nesting penalty of 3, nesting level increased to 4

(clang)


[note] 1092-1092: +1, nesting level increased to 4

(clang)


[warning] 1090-1090: repeated branch in conditional chain

(bugprone-branch-clone)


[note] 1092-1092: end of the original

(clang)


[note] 1092-1092: clone 1 starts here

(clang)

legacy/firmware/polkadot/parser_impl.h

[warning] 177-177: declaration uses identifier '_readCompactIndex', which is reserved in the global namespace

(bugprone-reserved-identifier)


[warning] 177-177: parameter name 'c' is too short, expected at least 3 characters

(readability-identifier-length)


[warning] 177-177: parameter name 'v' is too short, expected at least 3 characters

(readability-identifier-length)

legacy/firmware/polkadot/parser_impl_common.c

[warning] 348-348: the result from calling 'memcpy' is not null-terminated

(bugprone-not-null-terminated-result)


[warning] 352-352: the result from calling 'memcpy' is not null-terminated

(bugprone-not-null-terminated-result)


[warning] 356-356: the result from calling 'memcpy' is not null-terminated

(bugprone-not-null-terminated-result)


[warning] 356-356: 5 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 360-360: the result from calling 'memcpy' is not null-terminated

(bugprone-not-null-terminated-result)


[warning] 364-364: the result from calling 'memcpy' is not null-terminated

(bugprone-not-null-terminated-result)


[warning] 368-368: the result from calling 'memcpy' is not null-terminated

(bugprone-not-null-terminated-result)


[warning] 368-368: 6 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 372-372: the result from calling 'memcpy' is not null-terminated

(bugprone-not-null-terminated-result)


[warning] 377-377: the result from calling 'memcpy' is not null-terminated

(bugprone-not-null-terminated-result)


[warning] 381-381: the result from calling 'memcpy' is not null-terminated

(bugprone-not-null-terminated-result)


[warning] 381-381: 5 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)


[warning] 382-382: 11 is a magic number; consider replacing it with a named constant

(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)

🪛 Cppcheck (2.18.0)
legacy/firmware/usb.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

legacy/firmware/ethereum_onekey.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[error] 655-655: Using pointer to local variable 'temp_field_name' that is out of scope.

(invalidLifetime)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)

legacy/firmware/polkadot/substrate/substrate_types.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)

legacy/firmware/polkadot/tx.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[style] 9-9: The function 'polkadot_tx_parse' is never used.

(unusedFunction)

legacy/firmware/polkadot/parser_impl.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)

legacy/firmware/layout2.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

legacy/firmware/polkadot.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[style] 141-141: The function 'bn_copy' is never used.

(unusedFunction)


[style] 134-134: The function 'polkadot_sign_tx' is never used.

(unusedFunction)

legacy/firmware/polkadot/substrate/substrate_dispatch_V26.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[style] 122-122: The function 'int32_to_str' is never used.

(unusedFunction)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[style] 152-152: The function 'int64_to_str' is never used.

(unusedFunction)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[style] 349-349: The function 'pageString' is never used.

(unusedFunction)


[style] 356-356: The function 'fpuint64_to_str' is never used.

(unusedFunction)

legacy/firmware/polkadot/parser.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)

legacy/firmware/recovery.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)

legacy/firmware/polkadot/parser_impl_common.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[style] 356-356: The function 'fpuint64_to_str' is never used.

(unusedFunction)


[style] 341-341: The function 'getAddressType' is never used.

(unusedFunction)


[style] 344-344: The function 'detectNetworkMetadata' is never used.

(unusedFunction)


[style] 342-342: The function 'setAddressType' should have static linkage since it is not used outside of its translation unit.

(staticFunction)

legacy/firmware/config.c

[information] Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.

(normalCheckLevelMaxBranches)


[style] 274-274: The function 'oledClear_ext' is never used.

(unusedFunction)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Gen check
  • GitHub Check: Style check
  • GitHub Check: Defs check
🔇 Additional comments (22)
legacy/firmware/version.h (1)

10-13: LGTM! Version bump is consistent.

The minor version increment from 15 to 16 is correctly reflected in both the macro and the string constant.

legacy/script/i18n.py (1)

177-179: Confirm replace_breaks behaviour against Lokalise SDK

Adding "replace_breaks": 1 matches the later replace("\\n", " ") logic and should make comment generation more robust, but it does change how line breaks come back from Lokalise. Please confirm this flag is supported on your lokalise client version and that no other tooling relies on the old raw-newline behaviour.

legacy/firmware/recovery.c (1)

658-705: Refactor to ret correctly preserves cleanup on all exit paths

Using ret instead of early return makes sure enableLongPress(true) always runs, including after KEY_CONFIRM, while still signaling success/failure back to input_words. Behavior for both the normal flow (driven by word_index) and the re‑enter flow (driven by ret) stays intact. Nicely tightened control flow without changing semantics.

legacy/firmware/polkadot/substrate/substrate_coin.h (1)

21-22: LGTM! Clean macro additions.

The new ticker definitions follow the established pattern and integrate well with existing network support.

legacy/firmware/polkadot/substrate/substrate_dispatch_V26.c (2)

37-86: Hydration network support correctly integrated.

The dispatch mappings for module 7 (hydration) follow the same pattern as module 10 (Manta/Bifrost). The magic numbers flagged by static analysis are protocol-defined dispatch codes, which is standard for this firmware architecture.


88-101: Module name mapping looks good.

Hydration (module 7) properly mapped to STR_MO_BALANCES alongside other networks.

common/protob/messages-polkadot.proto (1)

39-39: Optional prefix field added for signing transactions.

Note that PolkadotGetAddress requires prefix (line 16) while PolkadotSignTx makes it optional. This asymmetry means signing can use defaults when prefix isn't provided.

legacy/firmware/polkadot/parser.c (1)

44-51: Address type fallback logic is sound.

When network detection fails, the code falls back to preset address type if available, otherwise defaults to 42 (Westend testnet). The static analysis warning about identical branches is a false positive—the branches pass different values to setAddressType.

legacy/firmware/polkadot/parser_common.h (1)

46-47: Clean context structure extension.

The new preset address type fields integrate well with the parsing flow changes.

legacy/firmware/polkadot/parser_txdef.h (1)

11-14: New asset location structure added.

The asset_location_t type captures hierarchical location with parents and interior fields. Both uint8_t types limit to 255 levels, which should be sufficient for Polkadot's asset location hierarchy.

legacy/firmware/polkadot/tx.h (1)

8-10: All callers updated correctly.

The search found one call site in legacy/firmware/polkadot.c:139-140, which passes all four required parameters: msg->raw_tx.bytes, msg->raw_tx.size, msg->has_prefix, and the conditional msg->has_prefix ? msg->prefix : 0. The function definition in legacy/firmware/polkadot/tx.c matches the declaration. No mismatched call sites detected.

legacy/firmware/polkadot/tx.c (1)

9-14: LGTM with a minor caveat.

The preset address type parameters are correctly propagated to the parsing context.

Note: dataLen (size_t), has_preset_address_type (bool), and preset_address_type (uint16_t) can be accidentally swapped at call sites. Consider reordering to separate the boolean from the numerics, or grouping related params into a struct.

legacy/firmware/polkadot/parser_impl.h (1)

175-179: LGTM. New address-type accessors look good.

The getter/setter pair and detectNetworkMetadata() are cleanly declared.

One note: detectNetworkMetadata() returns int8_t (-1/0), while most parser functions return parser_error_t. This inconsistency is minor but worth documenting.

legacy/firmware/polkadot/parser_impl_common.c (1)

341-342: LGTM. Simple accessor pair.

Clean getter/setter for the internal __address_type.

legacy/firmware/polkadot.c (1)

138-143: The address type is always initialized before use; no risk of stale or uninitialized data.

polkadot_tx_parse() indirectly calls polkadot_parser_parse(), which invokes detectNetworkMetadata() and always sets __address_type through setAddressType(). If detectNetworkMetadata() fails, polkadot_parser_parse() has fallback logic (lines 46–50 in legacy/firmware/polkadot/parser.c) that still calls setAddressType() with either a preset or default value. Since __address_type is a global variable with static storage duration, it will always be initialized before getAddressType() is called at line 143, even though this occurs before the ret error check at line 144.

legacy/firmware/ethereum_typed_data.h (1)

1045-1047: Long-press navigation implementation looks correct.

The enable/disable calls are properly paired. The static analysis warning about "repeated branch" at lines 1090 and 1092 is a false positive — these branches check different keys (KEY_UP vs KEY_DOWN).

This pattern matches existing long-press handling in layoutBlindSign and layoutNostrEncryptMessage.

Also applies to: 1088-1097, 1112-1114

legacy/firmware/layout2.c (1)

4393-4395: Long-press handling follows established patterns.

The implementation mirrors existing patterns in layoutBlindSign (line 4641) and layoutNostrEncryptMessage (line 5014). Enable/disable are properly paired.

The clang warning about "repeated branch in conditional chain" at line 4429 is a false positive. The branches test different key states (KEY_UP vs KEY_DOWN).

Also applies to: 4427-4436, 4451-4453

legacy/firmware/usb.c (1)

535-535: Correct placement for preserving safetyCheckLevel before soft reset

You snapshot the current SafetyCheckLevel after session_clear(true) and just before branching to reset_handler, which lines up with the restore logic in config_init and keeps the behavior soft‑reset–only. Looks good.

legacy/gd32_hard/memory_app_1.8.0_gd32.ld (1)

51-51: Preserved-data address is consistent with existing RAM layout

0x20010004 sits well inside the RAM region and next to _stay_in_bootloader_flag_addr, matching the pattern used in the other linker script. No functional issues here.

legacy/firmware/startup.S (1)

54-57: Preserving _preserved_reset_data_addr across RAM clear is implemented correctly

You save the word at _preserved_reset_data_addr into r11 before memset_reg and restore it afterward. memset_reg does not clobber r11, and the symbol is defined in the linker scripts, so the preserved data survives the RAM wipe as intended.

Also applies to: 63-66

legacy/firmware/config.c (1)

272-279: Soft‑reset restore of safetyCheckLevel is narrow and safe

Restoring only SafetyCheckLevel_PromptTemporarily from the preserved slot, then immediately clearing it, gives you the desired “survive USB‑triggered soft reset but not full power cycle” behavior without accidentally persisting more permissive modes. Once PRESERVED_RESET_DATA_INVALID is made available to EMULATOR builds in util.h (see my comment there), this block is solid.

legacy/memory_app_1.8.0.ld (1)

28-28: Preserved-data symbol is correctly placed in STM32 RAM

Defining _preserved_reset_data_addr at 0x20010004 mirrors the GD32 script and keeps the preserved-cell location consistent across platforms. No issues from a layout perspective.

guowei0105
guowei0105 previously approved these changes Dec 9, 2025
lihuanhuan
lihuanhuan previously approved these changes Dec 9, 2025
@somebodyLi somebodyLi enabled auto-merge (squash) December 10, 2025 02:15
@somebodyLi somebodyLi merged commit 2aad007 into master Dec 10, 2025
5 of 8 checks passed
@somebodyLi somebodyLi deleted the 3.16.0 branch December 10, 2025 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants