From ac07694309e313068dc123f514b8b2cbab666788 Mon Sep 17 00:00:00 2001 From: Andrzej Puzdrowski Date: Fri, 12 Jun 2020 16:35:02 +0200 Subject: [PATCH] storag/stream: fix stream_flash_bytes_written() return value stream_flash_bytes_written() returned number o bytes physically written to the flash. This number might be bigger than the requested number as is aligned to the device write-block-size. stream_flash_bytes_written() should return number of bytes written requested by the user. Signed-off-by: Andrzej Puzdrowski --- subsys/storage/stream/stream_flash.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/subsys/storage/stream/stream_flash.c b/subsys/storage/stream/stream_flash.c index 31705216008..48307536352 100644 --- a/subsys/storage/stream/stream_flash.c +++ b/subsys/storage/stream/stream_flash.c @@ -165,9 +165,12 @@ int stream_flash_buffered_write(struct stream_flash_ctx *ctx, const uint8_t *dat memset(ctx->buf + ctx->buf_bytes, filler, fill_length); ctx->buf_bytes += fill_length; + } else { + fill_length = 0; } rc = flash_sync(ctx); + ctx->bytes_written -= fill_length; } return rc;