Skip to contentSkip to conversation

selftests: dmabuf-heaps: print size_t with %zu

PATCH In review Sasha Levin 2 participants 2 messages Nov 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: dmabuf-heaps: print size_t with %zu

On 32-bit architectures size_t is an unsigned int, and printing it with %ld warns:

dmabuf-heap.c:215:43: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Wformat=]

Use %zu.

---
Found with a 32-bit build of the selftests with a 64-bit time_t (gcc 16 and clang 21 with -m32 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64); KernelCI's 32-bit arm builds show the same warnings. The changed files build without format warnings there now, and the x86_64 builds don't change. The other selftests get the same kind of fix in separate patches.

 tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +1 -1
index 1d49df6719198..c65efc088e88d 100644
@@ -212,7 +212,7 @@ static void test_alloc_zeroed(char *heap_name, size_t size)
 	void *p = NULL;
 	char *c;
 
-	ksft_print_msg("Testing alloced %ldk buffers are zeroed:\n", size / 1024);
+	ksft_print_msg("Testing alloced %zuk buffers are zeroed:\n", size / 1024);
 	heap_fd = dmabuf_heap_open(heap_name);
 
 	/* Allocate and fill a bunch of buffers */
Signature · 1 line
2.53.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Sasha Levin

On 32-bit architectures size_t is an unsigned int, and printing it with %ld warns:

dmabuf-heap.c:215:43: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Wformat=]

Use %zu.