iotex-core
iotex-core copied to clipboard
fix: fix slice init length
Description
The intention here should be to initialize a slice with a capacity of len(deviceArr) rather than initializing the length of this slice.
The online demo: https://go.dev/play/p/q1BcVCmvidW
Type of change
Please delete options that are not relevant.
- [] Bug fix (non-breaking change which fixes an issue)
- [] New feature (non-breaking change which adds functionality)
- [] Code refactor or improvement
- [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
- [] This change requires a documentation update
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
- [] make test
- [] fullsync
- [] Other test (please specify)
Test Configuration:
- Firmware version:
- Hardware:
- Toolchain:
- SDK:
Checklist:
- [] My code follows the style guidelines of this project
- [] I have performed a self-review of my code
- [] I have commented my code, particularly in hard-to-understand areas
- [] I have made corresponding changes to the documentation
- [] My changes generate no new warnings
- [] I have added tests that prove my fix is effective or that my feature works
- [] New and existing unit tests pass locally with my changes
- [] Any dependent changes have been merged and published in downstream modules
Thanks for the review. Anything need I to do?
Good catch, and curious about how to detect these issues?
Thanks for your review.
I have encountered many similar cases and developed a tool. I submitted a proposal a few days ago. If you are interested, please take a look. https://github.com/golang/go/issues/69872
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 74.73%. Comparing base (
436e4d1) to head (50b73f8). Report is 7 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #4412 +/- ##
==========================================
- Coverage 74.83% 74.73% -0.11%
==========================================
Files 378 378
Lines 31624 31719 +95
==========================================
+ Hits 23666 23704 +38
- Misses 6747 6799 +52
- Partials 1211 1216 +5
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
100.0% Duplication on New Code