From 5cc68ad3b887531a0eb3c1f9b1065acf90a94dec Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 26 Sep 2018 18:30:46 -0600 Subject: [PATCH] fs/spiffs: Fix yet another interface with NuttX MTD. This time, the calculatio of the terminal block number. --- fs/spiffs/src/spiffs_mtd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/spiffs/src/spiffs_mtd.c b/fs/spiffs/src/spiffs_mtd.c index 0cba815272..f3ada51c35 100644 --- a/fs/spiffs/src/spiffs_mtd.c +++ b/fs/spiffs/src/spiffs_mtd.c @@ -116,7 +116,7 @@ ssize_t spiffs_mtd_write(FAR struct spiffs_s *fs, off_t offset, size_t len, blkmask = blksize - 1; blkoffset = offset & blkmask; blkstart = offset / blksize; - blkend = (offset + len) / blksize; + blkend = (offset + len - 1) / blksize; /* Check if we have to do a read-modify-write on the first block. We * need to do this if the blkoffset is not zero. In that case we need @@ -269,7 +269,7 @@ ssize_t spiffs_mtd_read(FAR struct spiffs_s *fs, off_t offset, size_t len, blkmask = blksize - 1; blkoffset = offset & blkmask; blkstart = offset / blksize; - blkend = (offset + len) / blksize; + blkend = (offset + len - 1) / blksize; /* Check if we have to do a partial read on the first block. We * need to do this if the blkoffset is not zero. In that case we need