xhh233 opened a new pull request, #22368:
URL: https://github.com/apache/nuttx/pull/22368

   ## Summary
   
   In `mtdconfig_setconfig()`, when the payload write returns fewer bytes than 
requested, the error path rewrites `hdr.flags` with `MTD_ERASED_FLAGS(dev)` — 
the same value the header was written with a few lines earlier. The rewrite 
therefore changes nothing, and the partially written entry keeps a valid 
`id`/`instance`: `mtdconfig_findentry()` still returns it, so a later 
`getconfig()` reads a truncated payload instead of failing.
   
   Use the release marker that delete/overwrite already use 
(`(uint8_t)~MTD_ERASED_FLAGS(dev)`), so subsequent lookups skip the failed 
record and neither consolidation path copies it.
   
   ## Impact
   
   One-line behaviour change in the config-storage error path. Normal stores, 
overwrite and delete are unaffected; only a failed payload write now leaves the 
entry marked released instead of looking valid.
   
   ## Testing
   
   Deterministic MTD shim that fails the payload write after the header was 
written:
   
   * before: `setconfig()` returns `-EIO`, `getconfig()` for the same id still 
succeeds and returns a truncated payload (this is the reported behaviour)
   * after: `setconfig()` returns `-EIO`, `getconfig()` returns `-ENOENT`
   
   The shim models the driver logic; no board or QEMU run is claimed.
   
   ## AI declaration
   
   AI tools were used: OpenAI GPT (codex CLI) for review of the claim and the 
change before submission, and opencode agents driving DeepSeek models for 
source analysis and drafting. The final change was reviewed by the contributor 
and verified with the host shim described above. Issue reference: #22314.


-- 
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]

Reply via email to