-
Notifications
You must be signed in to change notification settings - Fork 9
feat(legacy): adaptation related to Polkadot updates #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
WalkthroughPreserve 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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Areas needing careful review:
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration 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:
📒 Files selected for processing (17)
🧰 Additional context used🧬 Code graph analysis (6)legacy/firmware/usb.c (3)
legacy/firmware/polkadot.c (2)
legacy/firmware/layout2.c (2)
legacy/firmware/ethereum_typed_data.h (1)
legacy/firmware/config.c (1)
legacy/firmware/ethereum_onekey.c (1)
🪛 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)
Comment |
There was a problem hiding this 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.
📒 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: Confirmreplace_breaksbehaviour against Lokalise SDKAdding
"replace_breaks": 1matches the laterreplace("\\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 yourlokaliseclient version and that no other tooling relies on the old raw-newline behaviour.legacy/firmware/recovery.c (1)
658-705: Refactor toretcorrectly preserves cleanup on all exit pathsUsing
retinstead of earlyreturnmakes sureenableLongPress(true)always runs, including afterKEY_CONFIRM, while still signaling success/failure back toinput_words. Behavior for both the normal flow (driven byword_index) and the re‑enter flow (driven byret) 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 conditionalmsg->has_prefix ? msg->prefix : 0. The function definition inlegacy/firmware/polkadot/tx.cmatches 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), andpreset_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()returnsint8_t(-1/0), while most parser functions returnparser_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 callspolkadot_parser_parse(), which invokesdetectNetworkMetadata()and always sets__address_typethroughsetAddressType(). IfdetectNetworkMetadata()fails,polkadot_parser_parse()has fallback logic (lines 46–50 inlegacy/firmware/polkadot/parser.c) that still callssetAddressType()with either a preset or default value. Since__address_typeis a global variable with static storage duration, it will always be initialized beforegetAddressType()is called at line 143, even though this occurs before thereterror 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_UPvsKEY_DOWN).This pattern matches existing long-press handling in
layoutBlindSignandlayoutNostrEncryptMessage.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) andlayoutNostrEncryptMessage(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_UPvsKEY_DOWN).Also applies to: 4427-4436, 4451-4453
legacy/firmware/usb.c (1)
535-535: Correct placement for preserving safetyCheckLevel before soft resetYou snapshot the current
SafetyCheckLevelaftersession_clear(true)and just before branching toreset_handler, which lines up with the restore logic inconfig_initand 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
0x20010004sits 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_addracross RAM clear is implemented correctlyYou save the word at
_preserved_reset_data_addrintor11beforememset_regand restore it afterward.memset_regdoes not clobberr11, 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 ofsafetyCheckLevelis narrow and safeRestoring only
SafetyCheckLevel_PromptTemporarilyfrom 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. OncePRESERVED_RESET_DATA_INVALIDis made available to EMULATOR builds inutil.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 RAMDefining
_preserved_reset_data_addrat0x20010004mirrors the GD32 script and keeps the preserved-cell location consistent across platforms. No issues from a layout perspective.
15302f6
Summary by CodeRabbit
New Features
Improvements
Localization
Chores
✏️ Tip: You can customize this high-level summary in your review settings.