ARM: dma-mapping: Use %zu for printing a size_t variable
PATCH 1/1 ARM: dma-mapping: Use %zu for printing a size_t variable
From: Fabio Estevam <[email protected]>
According to Documentation/printk-formats.txt when printing a size_t variable we should use %zu or %zx format specifiers.
As we are printing a memory size value, we should better use %zu in this case.
--- arch/arm/mm/dma-mapping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mm/dma-mapping.c +2 -2
@@ -436,7 +436,7 @@ static int __init atomic_pool_init(void)gen_pool_set_algo (atomic_pool, gen_pool_first_fit_order_align, (void *)PAGE_SHIFT ); -pr_info ("DMA: preallocated %zd KiB pool for atomic coherent allocations\n" , +pr_info ("DMA: preallocated %zu KiB pool for atomic coherent allocations\n" , atomic_pool_size /1024 );return 0 ; }
@@ -445,7 +445,7 @@ destroy_genpool:gen_pool_destroy (atomic_pool); atomic_pool =NULL ; out: -pr_err ("DMA: failed to allocate %zx KiB pool for atomic coherent allocation\n" , +pr_err ("DMA: failed to allocate %zu KiB pool for atomic coherent allocation\n" , atomic_pool_size /1024 );return -ENOMEM ; }
Signature · 1 line
1.9.1
PATCH 1/1 ARM: dma-mapping: Use %zu for printing a size_t variable
Quoted 28 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
According to
Documentation/printk-formats.txtwhen printing asize_tvariable we should use %zu or %zx format specifiers.As we are printing a memory size value, we should better use %zu in this case.
Reported-by Frank Mori Hess <[email protected]>Signed-off-by Fabio Estevam <[email protected]>--- arch/arm/mm/dma-mapping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/mm/dma-mapping.c +1
-1@@ -436,7 +436,7 @@ static int __init atomic_pool_init(void)gen_pool_set_algo (atomic_pool, gen_pool_first_fit_order_align, (void *)PAGE_SHIFT ); -pr_info ("DMA: preallocated %zd KiB pool for atomic coherent allocations\n" , +pr_info ("DMA: preallocated %zu KiB pool for atomic coherent allocations\n" , atomic_pool_size /1024 );return 0 ; }
arch/arm/mm/dma-mapping.c destroy_genpool: · line 448
Quoted 5 lines
arch/arm/mm/dma-mapping.c +1
-1@@ -445,7 +445,7 @@ destroy_genpool:gen_pool_destroy (atomic_pool); atomic_pool =NULL ; out: - pr_err("DMA: failed to allocate %zx KiB pool for atomic coherent allocation\n", + pr_err("DMA: failed to allocate %zu KiB pool for atomic coherent allocation\n",
size_t should be formated as %zu or %zx so %zx is fine here.
Quoted 4 lines
arch/arm/mm/dma-mapping.c +0
-0atomic_pool_size / 1024);return -ENOMEM ; }
PATCH 1/1 ARM: dma-mapping: Use %zu for printing a size_t variable
Quoted 1 line · Matthias Brugger
size_tshould be formated as %zu or %zx so %zx is fine here.
We are printing memory size here, so we should better print it in decimal instead of hex.
For example: let's suppose we want to print that 256kiB allocation failed.
If we use %zu:
DMA: failed to allocate 256KiB pool for atomic coherent allocation
If we use %zx:
DMA: failed to allocate 100KiB pool for atomic coherent allocation
,which is not really what we want.
PATCH 1/1 ARM: dma-mapping: Use %zu for printing a size_t variable
Quoted 10 lines · Fabio Estevam
Quoted 1 line · Matthias Brugger
size_tshould be formated as %zu or %zx so %zx is fine here.We are printing memory size here, so we should better print it in decimal instead of hex.
For example: let's suppose we want to print that 256kiB allocation failed.
Quoted 8 lines
If we use %zu:
DMA: failed to allocate 256KiB pool for atomic coherent allocationIf we use %zx:
DMA: failed to allocate 100KiB pool for atomic coherent allocation,which is not really what we want.
Fair enough, didn't realize that.
Russell King - ARM Linux
maintainerPATCH 1/1 ARM: dma-mapping: Use %zu for printing a size_t variable
In reply to Matthias BruggerQuoted 7 lines · Matthias Brugger
arch/arm/mm/dma-mapping.c destroy_genpool: · line 448
Quoted 2 lines · Fabio Estevam
arch/arm/mm/dma-mapping.c +1
-1- pr_err("DMA: failed to allocate %zx KiB pool for atomic coherent allocation\n", + pr_err("DMA: failed to allocate %zu KiB pool for atomic coherent allocation\n",
size_tshould be formated as %zu or %zx so %zx is fine here.
However, when it prints:
DMA: failed to allocate 100 KiB pool for atomic coherent allocation
how are you going to interpret it if you don't know the format string?
This change is exactly the right thing to do here.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.