Skip to contentSkip to conversation

memblock: fix format strings for panics after memblock_alloc

PATCH New Mike Rapoport 1 participant 1 message Jan 31, 2019

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

PATCH 1/1 memblock: fix format strings for panics after memblock_alloc

Using "%lu" to print size_t variables causes build warnings on i386 and probably other architectures:

kernel/dma/swiotlb.c:210:35: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=]

      panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
                                    ~~^
                                    %u
            __func__, alloc_size, PAGE_SIZE);
                      ~~~~~~~~~~

Replace "%lu" with "%zu".

---

Andrew, can you please fold this into "treewide: add checks for the return value of memblock_alloc*()"?

 arch/x86/platform/olpc/olpc_dt.c | 2 +-
 kernel/dma/swiotlb.c             | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/platform/olpc/olpc_dt.c +1 -1
index dad3b60..ac9e7bf 100644
@@ -142,7 +142,7 @@ void * __init prom_early_alloc(unsigned long size)
 		 */
 		res = memblock_alloc(chunk_size, SMP_CACHE_BYTES);
 		if (!res)
-			panic("%s: Failed to allocate %lu bytes\n", __func__,
+			panic("%s: Failed to allocate %zu bytes\n", __func__,
 			      chunk_size);
 		BUG_ON(!res);
 		prom_early_allocated += chunk_size;
kernel/dma/swiotlb.c +2 -2
index b64b500..ad33fee 100644
@@ -207,13 +207,13 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
 	alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(int));
 	io_tlb_list = memblock_alloc(alloc_size, PAGE_SIZE);
 	if (!io_tlb_list)
-		panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
+		panic("%s: Failed to allocate %zu bytes align=0x%lx\n",
 		      __func__, alloc_size, PAGE_SIZE);
 
 	alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t));
 	io_tlb_orig_addr = memblock_alloc(alloc_size, PAGE_SIZE);
 	if (!io_tlb_orig_addr)
-		panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
+		panic("%s: Failed to allocate %zu bytes align=0x%lx\n",
 		      __func__, alloc_size, PAGE_SIZE);
 
 	for (i = 0; i < io_tlb_nslabs; i++) {
Signature · 1 line
2.7.4