xhh233 opened a new pull request, #22379: URL: https://github.com/apache/nuttx/pull/22379
## Summary `mtdconfig_ramconsolidate()` and `mtdconfig_consolidate()` return an offset on success, but returned `0` on every error path. `mtdconfig_setconfig()` ignores that value, retries the free-entry search, and can then report `-ENOMEM` even though the real failure was an I/O error during consolidation. Both helpers now return the negative error (and `-ENOMEM` when the temporary buffer cannot be allocated), and the two call sites in `mtdconfig_setconfig()` check the `off_t` result before narrowing it, so a failed consolidation reaches the caller with its original error code. ## Impact Error reporting only for the failure path. Successful consolidation is unchanged (`SET` still retries the search after a successful pass). The helpers have no other callers, so no consumer depends on the old `0`-means-error convention. ## Testing Source-level change with no dynamic harness: the two helpers have exactly two call sites (both patched), and each returns a positive offset on success or a negative errno after the change, which the call sites now test before narrowing to `int`. ## AI declaration AI tools were used: OpenAI GPT (codex CLI) for review before submission — it rejected an earlier version that narrowed the `off_t` result into `int` at the call sites — and opencode agents driving DeepSeek models for source analysis and drafting. The final change was reviewed by the contributor. Issue reference: #22316. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
