Skip to content

Fix uninitialized mapped sector state in NOR erase block search - #83

Open
miracoli wants to merge 1 commit into
eclipse-threadx:masterfrom
miracoli:agent/fix-uninitialized-mapped-sector-count
Open

Fix uninitialized mapped sector state in NOR erase block search#83
miracoli wants to merge 1 commit into
eclipse-threadx:masterfrom
miracoli:agent/fix-uninitialized-mapped-sector-count

Conversation

@miracoli

Copy link
Copy Markdown

Summary

Fix potentially uninitialized mapped sector state in _lx_nor_flash_next_block_to_erase_find().

Depending on the control flow, the obsolete sector count may be obtained from the cache or block metadata without scanning the physical sector mapping table. In these cases, mapped_sectors was subsequently copied into candidate block information without being initialized for the current block.

Additionally, mapped_sectors_available was declared without an initial value and is checked after the block search loop. This caused compilers such as GCC to report -Wmaybe-uninitialized warnings, for example:

warning: 'mapped_sectors_available' may be used uninitialized [-Wmaybe-uninitialized]

The change:

  • initializes mapped_sectors_available to LX_FALSE at declaration;
  • resets mapped_sectors to 0 for every block iteration;
  • keeps the existing availability flag logic intact.

When the mapped sector count is unavailable, LevelX still computes the actual count for the selected erase block before returning it. The change therefore removes the compiler warnings and prevents stale or indeterminate intermediate values without changing the erase-block selection behavior.

@fdesbiens

Copy link
Copy Markdown
Contributor

Hi @miracoli.

Thank you for this contribution. @rahmanih, Would you be so kind as to review it, please?

@fdesbiens
fdesbiens requested a review from rahmanih July 28, 2026 14:54
@fdesbiens fdesbiens moved this to In review in ThreadX Roadmap Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants