@@ -225,9 +225,9 @@ void setEntityValue(page_iterator_t &entity, uint16_t offset, byte value)
225225// ========================= Static page size computation & checking ===================
226226
227227// This will fail AND print the page number and required size
228- template <uint8_t pageNum, uint16_t min >
228+ template <uint8_t pageNum, uint16_t pageSize >
229229static inline void check_size (void ) {
230- static_assert (ini_page_sizes[pageNum] >= min , " Size is off!" );
230+ static_assert (ini_page_sizes[pageNum] == pageSize , " Size is off!" );
231231}
232232
233233// Since pages are a logical contiguous block, we can automatically compute the
@@ -301,6 +301,23 @@ static inline page_iterator_t create_raw_iterator(void *pBuffer, uint8_t pageNum
301301 } \
302302 DECLARE_NEXT_ENTITY_START (entityNum, blockSize)
303303
304+ // ========================= Empty entity processing ===================
305+
306+ static inline page_iterator_t create_empty_iterator(uint8_t pageNum, uint8_t index, uint16_t start, uint16_t size)
307+ {
308+ return page_iterator_t ( NoEntity,
309+ entity_page_location_t (pageNum, index),
310+ entity_page_address_t (start, size));
311+ }
312+
313+ // If the offset is in range, create a "no entity"
314+ #define CHECK_NOENTITY (pageNum, offset, blockSize, entityNum ) \
315+ if (offset < ENTITY_START_VAR(entityNum)+blockSize) \
316+ { \
317+ return create_empty_iterator ((pageNum), (entityNum), ENTITY_START_VAR (entityNum), (blockSize));\
318+ } \
319+ DECLARE_NEXT_ENTITY_START (entityNum, blockSize)
320+
304321// ===============================================================================
305322
306323// Does the heavy lifting of mapping page+offset to an entity
@@ -385,7 +402,8 @@ page_iterator_t map_page_offset_to_entity(uint8_t pageNumber, uint16_t offset)
385402 // LCOV_EXCL_BR_STOP
386403 CHECK_TABLE (wmiMapPage, offset, &vvt2Table, 1 )
387404 CHECK_TABLE (wmiMapPage, offset, &dwellTable, 2 )
388- END_OF_PAGE (wmiMapPage, 3 )
405+ CHECK_NOENTITY (wmiMapPage, offset, 8U , 3 )
406+ END_OF_PAGE (wmiMapPage, 4 )
389407 }
390408
391409 case ignMap2Page:
0 commit comments