mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
tests/periph_flashpage_unittests: use unsgined int for address cast
For 16bit platforms casting to int will overflow when ROM size nears 2**16
This commit is contained in:
parent
7d10831254
commit
9bda6b2938
@ -46,11 +46,12 @@ static void test_flashbase_addr(void)
|
|||||||
void *addr;
|
void *addr;
|
||||||
|
|
||||||
addr = flashpage_addr(0);
|
addr = flashpage_addr(0);
|
||||||
TEST_ASSERT_EQUAL_INT((int)CPU_FLASH_BASE, (int)addr);
|
TEST_ASSERT_EQUAL_INT((unsigned int)CPU_FLASH_BASE, (unsigned int)addr);
|
||||||
addr = flashpage_addr(FLASHPAGE_NUMOF - 1);
|
addr = flashpage_addr(FLASHPAGE_NUMOF - 1);
|
||||||
TEST_ASSERT_EQUAL_INT((long)CPU_FLASH_BASE + (((unsigned)FLASHPAGE_NUMOF - 1) * FLASHPAGE_SIZE), (int)addr);
|
TEST_ASSERT_EQUAL_INT((long)CPU_FLASH_BASE + (((unsigned)FLASHPAGE_NUMOF - 1) * FLASHPAGE_SIZE),
|
||||||
|
(unsigned int)addr);
|
||||||
addr = flashpage_addr(12);
|
addr = flashpage_addr(12);
|
||||||
TEST_ASSERT_EQUAL_INT((int)CPU_FLASH_BASE + (12 * FLASHPAGE_SIZE), (int)addr);
|
TEST_ASSERT_EQUAL_INT((unsigned int)CPU_FLASH_BASE + (12 * FLASHPAGE_SIZE), (unsigned int)addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_flashbase_page(void)
|
static void test_flashbase_page(void)
|
||||||
@ -65,7 +66,9 @@ static void test_flashbase_page(void)
|
|||||||
TEST_ASSERT_EQUAL_INT(1, page);
|
TEST_ASSERT_EQUAL_INT(1, page);
|
||||||
page = flashpage_page((void *)(CPU_FLASH_BASE + FLASHPAGE_SIZE + 1));
|
page = flashpage_page((void *)(CPU_FLASH_BASE + FLASHPAGE_SIZE + 1));
|
||||||
TEST_ASSERT_EQUAL_INT(1, page);
|
TEST_ASSERT_EQUAL_INT(1, page);
|
||||||
page = flashpage_page((void *)(CPU_FLASH_BASE + ((unsigned)FLASHPAGE_SIZE * (FLASHPAGE_NUMOF - 1))));
|
page =
|
||||||
|
flashpage_page((void *)(CPU_FLASH_BASE +
|
||||||
|
((unsigned)FLASHPAGE_SIZE * (FLASHPAGE_NUMOF - 1))));
|
||||||
TEST_ASSERT_EQUAL_INT(FLASHPAGE_NUMOF - 1, page);
|
TEST_ASSERT_EQUAL_INT(FLASHPAGE_NUMOF - 1, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user