Skip to content

fix(RegionMap): load() returns actual read success instead of hardcoded true - #2917

Merged
ripplebiz merged 1 commit into
meshcore-dev:devfrom
jirogit:fix/regionmap-load-eof-handling
Jul 13, 2026
Merged

fix(RegionMap): load() returns actual read success instead of hardcoded true#2917
ripplebiz merged 1 commit into
meshcore-dev:devfrom
jirogit:fix/regionmap-load-eof-handling

Conversation

@jirogit

@jirogit jirogit commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Companion fix to #2372, which fixed the same `return true` hardcoding
in save(). load() has the same issue — it ignores read failures and
always returns true regardless of what happened during the read loop.

(Note: #1891 originally reported this on load(), but was closed when
#2372 landed — that PR only touched save(). This PR addresses the
load() side.)

Fix distinguishes:

  • Clean EOF (read() returns 0 bytes on the id field) → normal end of
    a variable-length region list, success unaffected
  • Partial/corrupted record (fewer bytes than expected mid-record) →
    real failure, success=false

Verified on Wio Tracker L1 Pro (companion firmware): wrote 3 regions
via `region put`, rebooted, confirmed all 3 persisted correctly after
reboot — the clean-EOF path in load() does not regress normal loads.

Previously load() returned true unconditionally on file-open success,
masking truncated or corrupt /regions2 files. Additionally, the first
field of each entry record (r->id) used the same success-chaining
pattern as subsequent fields, so a clean EOF at a record boundary set
success=false and would have been indistinguishable from real
corruption once the return value was fixed.

The r->id read is now split out: n==0 is a clean EOF (break, success
retains its prior value from the header read), n!=sizeof(r->id) is a
partial read or corruption (break, success=false). load() now returns
success instead of an unconditional true, so its return value reflects
the actual parse outcome.

Companion fix to meshcore-dev#2372, which fixed the same return-true hardcoding
in save(). (meshcore-dev#1891 originally reported this on load() but was closed
when meshcore-dev#2372 landed — that PR only touched save(); this addresses the
load() side.)
@ripplebiz
ripplebiz merged commit b81fb8e into meshcore-dev:dev Jul 13, 2026
12 checks passed
@jirogit
jirogit deleted the fix/regionmap-load-eof-handling branch July 21, 2026 03:05
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.

2 participants