Skip to contentSkip to conversation

ARM: Wrong size used in dump_mem()

PATCH In review Roel Kluin 2 participants 3 messages Dec 17, 2009 Arm (32-bit)

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 ARM: Wrong size used in dump_mem()

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

---
Unless I am mistaken?

arch/arm/kernel/traps.c +1 -1
index 3f361a7..5e828fa 100644
@@ -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) {
#1 lore raw
Quoted 5 lines · Roel Kluin

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

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

Quoted 13 lines
arch/arm/kernel/traps.c +1 -1
index 3f361a7..5e828fa 100644
@@ -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) {
author
#2 lore raw
Quoted 7 lines · Russell King - ARM Linux
Quoted 5 lines · Roel Kluin

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

---
Unless I am mistaken?

Quoted 5 lines

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