Skip to content

Commit 4616000

Browse files
committed
tests/mem_blocks_stats: Improve compatibility with 64-bit platforms
Use %zu format specifier only for size_t type to ensure compatibility with both 32-bit and 64-bit platforms. Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
1 parent 08c1130 commit 4616000

File tree

1 file changed

+16
-16
lines changed
  • tests/lib/mem_blocks_stats/src

1 file changed

+16
-16
lines changed

tests/lib/mem_blocks_stats/src/main.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ZTEST(lib_mem_blocks_stats_test, test_mem_blocks_runtime_stats)
5656
zassert_equal(status, 0, "Routine failed with status %d\n", status);
5757

5858
zassert_equal(stats.free_bytes, BLK_SZ * NUM_BLOCKS,
59-
"Expected %zu free bytes, not %zu\n",
59+
"Expected %u free bytes, not %zu\n",
6060
BLK_SZ * NUM_BLOCKS, stats.free_bytes);
6161
zassert_equal(stats.allocated_bytes, 0,
6262
"Expected 0 allocated bytes, not %zu\n",
@@ -74,13 +74,13 @@ ZTEST(lib_mem_blocks_stats_test, test_mem_blocks_runtime_stats)
7474
zassert_equal(status, 0, "Routine failed with status %d\n", status);
7575

7676
zassert_equal(stats.free_bytes, BLK_SZ * (NUM_BLOCKS - 3),
77-
"Expected %zu free bytes, not %zu\n",
77+
"Expected %u free bytes, not %zu\n",
7878
BLK_SZ * (NUM_BLOCKS - 3), stats.free_bytes);
7979
zassert_equal(stats.allocated_bytes, 3 * BLK_SZ,
80-
"Expected %zu allocated bytes, not %zu\n",
80+
"Expected %u allocated bytes, not %zu\n",
8181
3 * BLK_SZ, stats.allocated_bytes);
8282
zassert_equal(stats.max_allocated_bytes, 3 * BLK_SZ,
83-
"Expected %zu max allocated bytes, not %zu\n",
83+
"Expected %u max allocated bytes, not %zu\n",
8484
3 * BLK_SZ, stats.max_allocated_bytes);
8585

8686
/* Free blocks 1 and 2, and then verify the stats. */
@@ -92,13 +92,13 @@ ZTEST(lib_mem_blocks_stats_test, test_mem_blocks_runtime_stats)
9292
zassert_equal(status, 0, "Routine failed with status %d\n", status);
9393

9494
zassert_equal(stats.free_bytes, BLK_SZ * (NUM_BLOCKS - 1),
95-
"Expected %zu free bytes, not %zu\n",
95+
"Expected %u free bytes, not %zu\n",
9696
BLK_SZ * (NUM_BLOCKS - 1), stats.free_bytes);
9797
zassert_equal(stats.allocated_bytes, 1 * BLK_SZ,
98-
"Expected %zu allocated bytes, not %zu\n",
98+
"Expected %u allocated bytes, not %zu\n",
9999
1 * BLK_SZ, stats.allocated_bytes);
100100
zassert_equal(stats.max_allocated_bytes, 3 * BLK_SZ,
101-
"Expected %zu max allocated bytes, not %zu\n",
101+
"Expected %u max allocated bytes, not %zu\n",
102102
3 * BLK_SZ, stats.max_allocated_bytes);
103103

104104
/* Allocate 1 block and verify the max is still at 3 */
@@ -110,13 +110,13 @@ ZTEST(lib_mem_blocks_stats_test, test_mem_blocks_runtime_stats)
110110
zassert_equal(status, 0, "Routine failed with status %d\n", status);
111111

112112
zassert_equal(stats.free_bytes, BLK_SZ * (NUM_BLOCKS - 2),
113-
"Expected %zu free bytes, not %zu\n",
113+
"Expected %u free bytes, not %zu\n",
114114
BLK_SZ * (NUM_BLOCKS - 2), stats.free_bytes);
115115
zassert_equal(stats.allocated_bytes, 2 * BLK_SZ,
116-
"Expected %zu allocated bytes, not %zu\n",
116+
"Expected %u allocated bytes, not %zu\n",
117117
2 * BLK_SZ, stats.allocated_bytes);
118118
zassert_equal(stats.max_allocated_bytes, 3 * BLK_SZ,
119-
"Expected %zu max allocated bytes, not %zu\n",
119+
"Expected %u max allocated bytes, not %zu\n",
120120
3 * BLK_SZ, stats.max_allocated_bytes);
121121

122122

@@ -129,13 +129,13 @@ ZTEST(lib_mem_blocks_stats_test, test_mem_blocks_runtime_stats)
129129
zassert_equal(status, 0, "Routine failed with status %d\n", status);
130130

131131
zassert_equal(stats.free_bytes, BLK_SZ * (NUM_BLOCKS - 2),
132-
"Expected %zu free bytes, not %zu\n",
132+
"Expected %u free bytes, not %zu\n",
133133
BLK_SZ * (NUM_BLOCKS - 2), stats.free_bytes);
134134
zassert_equal(stats.allocated_bytes, 2 * BLK_SZ,
135-
"Expected %zu allocated bytes, not %zu\n",
135+
"Expected %u allocated bytes, not %zu\n",
136136
2 * BLK_SZ, stats.allocated_bytes);
137137
zassert_equal(stats.max_allocated_bytes, 2 * BLK_SZ,
138-
"Expected %zu max allocated bytes, not %zu\n",
138+
"Expected %u max allocated bytes, not %zu\n",
139139
2 * BLK_SZ, stats.max_allocated_bytes);
140140

141141
/* Free the last two blocks; verify stats results */
@@ -147,13 +147,13 @@ ZTEST(lib_mem_blocks_stats_test, test_mem_blocks_runtime_stats)
147147
zassert_equal(status, 0, "Routine failed with status %d\n", status);
148148

149149
zassert_equal(stats.free_bytes, BLK_SZ * NUM_BLOCKS,
150-
"Expected %zu free bytes, not %zu\n",
150+
"Expected %u free bytes, not %zu\n",
151151
BLK_SZ * NUM_BLOCKS, stats.free_bytes);
152152
zassert_equal(stats.allocated_bytes, 0,
153-
"Expected %zu allocated bytes, not %zu\n",
153+
"Expected %u allocated bytes, not %zu\n",
154154
0, stats.allocated_bytes);
155155
zassert_equal(stats.max_allocated_bytes, 2 * BLK_SZ,
156-
"Expected %zu max allocated bytes, not %zu\n",
156+
"Expected %u max allocated bytes, not %zu\n",
157157
2 * BLK_SZ, stats.max_allocated_bytes);
158158
}
159159

0 commit comments

Comments
 (0)