storage/stream/flash: flash_sync: Check if there is anything to write

The commit moves block that checks if flash_stream_ctx.buf_bytes
is non-zero out of CONFIG_STREAM_FLASH_ERASE specific code,  as that is
universal check and is valid also for not CONFIG_STREAM_FLASH_ERASE
code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2021-02-19 12:45:21 +00:00 committed by Ioannis Glaropoulos
parent cfb056901c
commit 5a1750b053

View file

@ -56,10 +56,11 @@ static int flash_sync(struct stream_flash_ctx *ctx)
size_t write_addr = ctx->offset + ctx->bytes_written;
if (ctx->buf_bytes == 0) {
return 0;
}
if (IS_ENABLED(CONFIG_STREAM_FLASH_ERASE)) {
if (ctx->buf_bytes == 0) {
return 0;
}
rc = stream_flash_erase_page(ctx,
write_addr + ctx->buf_bytes - 1);