From 8cda6b097ef3988f2c3ea7d93d0658bebaae1803 Mon Sep 17 00:00:00 2001 From: batt Date: Wed, 2 Feb 2011 21:00:18 +0000 Subject: [PATCH] Take into account also the start block on trimmed devices. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4673 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/drv/eeprom.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bertos/drv/eeprom.c b/bertos/drv/eeprom.c index 4fe444e9..26bd90fb 100644 --- a/bertos/drv/eeprom.c +++ b/bertos/drv/eeprom.c @@ -181,9 +181,8 @@ static size_t eeprom_write(KBlock *blk, block_idx_t idx, const void *buf, size_t STATIC_ASSERT(countof(addr_buf) <= sizeof(e2addr_t)); - /* clamp size to memory limit (otherwise may roll back) */ - ASSERT(idx <= blk->blk_cnt); + ASSERT(idx < blk->priv.blk_start + blk->blk_cnt); size = MIN(size, blk->blk_size - offset); if (mem_info[eep->type].has_dev_addr) @@ -230,7 +229,7 @@ static size_t eeprom_readDirect(struct KBlock *_blk, block_idx_t idx, void *_buf STATIC_ASSERT(countof(addr_buf) <= sizeof(e2addr_t)); /* clamp size to memory limit (otherwise may roll back) */ - ASSERT(idx <= blk->blk.blk_cnt); + ASSERT(idx < blk->blk.priv.blk_start + blk->blk.blk_cnt); size = MIN(size, blk->blk.blk_size - offset); e2dev_addr_t dev_addr; -- 2.25.1