Skip to content

Commit feb3d54

Browse files
tpamborcfriedt
authored andcommitted
tests: drivers: flash: Improve compatibility with 64-bit platforms
Change variables in test_cb_data_type from uint32_t to size_t to match the return type of flash_get_page_count() and adjust format specifiers accordingly. This resolves warnings when compiling for 64-bit platforms. Signed-off-by: Tim Pambor <[email protected]>
1 parent c78e45a commit feb3d54

File tree

1 file changed

+5
-5
lines changed
  • tests/drivers/flash/common/src

1 file changed

+5
-5
lines changed

tests/drivers/flash/common/src/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ ZTEST(flash_driver, test_supply_gpios_control)
347347
}
348348

349349
struct test_cb_data_type {
350-
uint32_t page_counter; /* used to count how many pages was iterated */
351-
uint32_t exit_page; /* terminate iteration when this page is reached */
350+
size_t page_counter; /* used to count how many pages was iterated */
351+
size_t exit_page; /* terminate iteration when this page is reached */
352352
};
353353

354354
static bool flash_callback(const struct flash_pages_info *info, void *data)
@@ -407,23 +407,23 @@ ZTEST(flash_driver, test_flash_page_layout)
407407
zassert_equal(page_info_off.index, page_info_idx.index);
408408

409409
page_count = flash_get_page_count(flash_dev);
410-
TC_PRINT("page_count=%d\n", (int)page_count);
410+
TC_PRINT("page_count=%zu\n", page_count);
411411
zassert_true(page_count > 0, "flash_get_page_count returned %d", rc);
412412
zassert_true(page_count >= page_info_off.index);
413413

414414
/* Test that callback is executed for every page */
415415
test_cb_data.exit_page = page_count + 1;
416416
flash_page_foreach(flash_dev, flash_callback, &test_cb_data);
417417
zassert_true(page_count == test_cb_data.page_counter,
418-
"page_count = %d not equal to pages counted with cb = %d", page_count,
418+
"page_count = %zu not equal to pages counted with cb = %zu", page_count,
419419
test_cb_data.page_counter);
420420

421421
/* Test that callback can cancell iteration */
422422
test_cb_data.page_counter = 0;
423423
test_cb_data.exit_page = page_count >> 1;
424424
flash_page_foreach(flash_dev, flash_callback, &test_cb_data);
425425
zassert_true(test_cb_data.exit_page == test_cb_data.page_counter,
426-
"%d pages were iterated while it shall stop on page %d",
426+
"%zu pages were iterated while it shall stop on page %zu",
427427
test_cb_data.page_counter, test_cb_data.exit_page);
428428
}
429429

0 commit comments

Comments
 (0)