linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: dma-mapping: Use %zu for printing a size_t variable
@ 2016-07-17  0:10 Fabio Estevam
  2016-07-18 16:03 ` Matthias Brugger
  0 siblings, 1 reply; 5+ messages in thread
From: Fabio Estevam @ 2016-07-17  0:10 UTC (permalink / raw)
  To: linux-arm-kernel

From: Fabio Estevam <fabio.estevam@nxp.com>

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.

Reported-by: Frank Mori Hess <fmh6jj@gmail.com>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 arch/arm/mm/dma-mapping.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 654f202a..5bcf71b 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -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;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] ARM: dma-mapping: Use %zu for printing a size_t variable
  2016-07-17  0:10 [PATCH] ARM: dma-mapping: Use %zu for printing a size_t variable Fabio Estevam
@ 2016-07-18 16:03 ` Matthias Brugger
  2016-07-18 16:11   ` Fabio Estevam
  2016-07-18 16:11   ` Russell King - ARM Linux
  0 siblings, 2 replies; 5+ messages in thread
From: Matthias Brugger @ 2016-07-18 16:03 UTC (permalink / raw)
  To: linux-arm-kernel



On 07/17/2016 02:10 AM, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
>
> 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.
>
> Reported-by: Frank Mori Hess <fmh6jj@gmail.com>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
>  arch/arm/mm/dma-mapping.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 654f202a..5bcf71b 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -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",

size_t should be formated as %zu or %zx so %zx is fine here.

>  	       atomic_pool_size / 1024);
>  	return -ENOMEM;
>  }
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ARM: dma-mapping: Use %zu for printing a size_t variable
  2016-07-18 16:03 ` Matthias Brugger
@ 2016-07-18 16:11   ` Fabio Estevam
  2016-07-18 16:23     ` Matthias Brugger
  2016-07-18 16:11   ` Russell King - ARM Linux
  1 sibling, 1 reply; 5+ messages in thread
From: Fabio Estevam @ 2016-07-18 16:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jul 18, 2016 at 1:03 PM, Matthias Brugger
<matthias.bgg@gmail.com> wrote:

> size_t should 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ARM: dma-mapping: Use %zu for printing a size_t variable
  2016-07-18 16:03 ` Matthias Brugger
  2016-07-18 16:11   ` Fabio Estevam
@ 2016-07-18 16:11   ` Russell King - ARM Linux
  1 sibling, 0 replies; 5+ messages in thread
From: Russell King - ARM Linux @ 2016-07-18 16:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jul 18, 2016 at 06:03:05PM +0200, Matthias Brugger wrote:
> 
> 
> On 07/17/2016 02:10 AM, Fabio Estevam wrote:
> >-	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.

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.

-- 
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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ARM: dma-mapping: Use %zu for printing a size_t variable
  2016-07-18 16:11   ` Fabio Estevam
@ 2016-07-18 16:23     ` Matthias Brugger
  0 siblings, 0 replies; 5+ messages in thread
From: Matthias Brugger @ 2016-07-18 16:23 UTC (permalink / raw)
  To: linux-arm-kernel



On 07/18/2016 06:11 PM, Fabio Estevam wrote:
> On Mon, Jul 18, 2016 at 1:03 PM, Matthias Brugger
> <matthias.bgg@gmail.com> wrote:
>
>> size_t should 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.
>

Fair enough, didn't realize that.

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-07-18 16:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-17  0:10 [PATCH] ARM: dma-mapping: Use %zu for printing a size_t variable Fabio Estevam
2016-07-18 16:03 ` Matthias Brugger
2016-07-18 16:11   ` Fabio Estevam
2016-07-18 16:23     ` Matthias Brugger
2016-07-18 16:11   ` Russell King - ARM Linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).