storage/stream/flash: Fix flash_sync updating bytes_written on failure
The flash_sync function is able to call, if specified, write verification callback to check whether data flash has been correctly written to a flash. Part of that procedure is to read date back of the flash and call the verification callback on the buffer; in case if the read would fail, the flash_sync would return, with an error code, without updating stream_flash_ctx. The same logic should be applied to failed verification, but, due to missing return, the stream_flash_ctx gets updated with probably incorrectly written bytes added to total bytes_written and buf_bytes, representing number of bytes awaiting in buffer, being zeroed. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
94968dfee4
commit
cfb056901c
2 changed files with 35 additions and 0 deletions
|
@ -98,6 +98,7 @@ static int flash_sync(struct stream_flash_ctx *ctx)
|
|||
rc = ctx->callback(ctx->buf, ctx->buf_bytes, write_addr);
|
||||
if (rc != 0) {
|
||||
LOG_ERR("callback failed: %d", rc);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue