linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: Wrong size used in dump_mem()
@ 2009-12-17 21:15 Roel Kluin
  2009-12-17 21:17 ` Russell King - ARM Linux
  0 siblings, 1 reply; 3+ messages in thread
From: Roel Kluin @ 2009-12-17 21:15 UTC (permalink / raw)
  To: linux-arm-kernel

The sizeof the pointed to should be used rather than of the pointer

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Unless I am mistaken?

diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 3f361a7..5e828fa 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -102,7 +102,7 @@ static void dump_mem(const char *lvl, const char *str, unsigned long bottom,
 		unsigned long p;
 		char str[sizeof(" 12345678") * 8 + 1];
 
-		memset(str, ' ', sizeof(str));
+		memset(str, ' ', sizeof(*str));
 		str[sizeof(str) - 1] = '\0';
 
 		for (p = first, i = 0; i < 8 && p < top; i++, p += 4) {

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

* [PATCH] ARM: Wrong size used in dump_mem()
  2009-12-17 21:15 [PATCH] ARM: Wrong size used in dump_mem() Roel Kluin
@ 2009-12-17 21:17 ` Russell King - ARM Linux
  2009-12-17 21:20   ` roel kluin
  0 siblings, 1 reply; 3+ messages in thread
From: Russell King - ARM Linux @ 2009-12-17 21:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 17, 2009 at 10:15:58PM +0100, Roel Kluin wrote:
> The sizeof the pointed to should be used rather than of the pointer
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> Unless I am mistaken?

You are mistaken.  sizeof(array) is the byte size of the array.
sizeof(*array) is the size of one individual object of the array.

The code is correct as is - which is to fill  the entire array with
space characters and then zero the last one.

> diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
> index 3f361a7..5e828fa 100644
> --- a/arch/arm/kernel/traps.c
> +++ b/arch/arm/kernel/traps.c
> @@ -102,7 +102,7 @@ static void dump_mem(const char *lvl, const char *str, unsigned long bottom,
>  		unsigned long p;
>  		char str[sizeof(" 12345678") * 8 + 1];
>  
> -		memset(str, ' ', sizeof(str));
> +		memset(str, ' ', sizeof(*str));
>  		str[sizeof(str) - 1] = '\0';
>  
>  		for (p = first, i = 0; i < 8 && p < top; i++, p += 4) {

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

* [PATCH] ARM: Wrong size used in dump_mem()
  2009-12-17 21:17 ` Russell King - ARM Linux
@ 2009-12-17 21:20   ` roel kluin
  0 siblings, 0 replies; 3+ messages in thread
From: roel kluin @ 2009-12-17 21:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 17, 2009 at 10:17 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Thu, Dec 17, 2009 at 10:15:58PM +0100, Roel Kluin wrote:
>> The sizeof the pointed to should be used rather than of the pointer
>>
>> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
>> ---
>> Unless I am mistaken?
>
> You are mistaken. ?sizeof(array) is the byte size of the array.
> sizeof(*array) is the size of one individual object of the array.
>
> The code is correct as is - which is to fill ?the entire array with
> space characters and then zero the last one.

hmm, I see. sorry for the noise

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

end of thread, other threads:[~2009-12-17 21:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-17 21:15 [PATCH] ARM: Wrong size used in dump_mem() Roel Kluin
2009-12-17 21:17 ` Russell King - ARM Linux
2009-12-17 21:20   ` roel kluin

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