Skip to contentSkip to conversation

powerpc: fix uninitialised error in numa.c

PATCH In review Michael Neuling 2 participants 4 messages Jun 20, 2012 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: fix uninitialised error in numa.c

chroma_defconfig currently gives me this with gcc 4.6:
arch/powerpc/mm/numa.c:638:13: error: 'dm' may be used uninitialized in this function [-Werror=uninitialized]

It's a bogus warning since of_get_drconf_memory() only writes it anyway.

---
Also affects 3.4 and 3.3 stable.

arch/powerpc/mm/numa.c +1 -1
index 5ca3a15..880acde 100644
@@ -637,7 +637,7 @@ static inline int __init read_usm_ranges(const u32 **usm)
  */
 static void __init parse_drconf_memory(struct device_node *memory)
 {
-	const u32 *dm, *usm;
+	const u32 *dm = NULL, *usm;
 	unsigned int n, rc, ranges, is_kexec_kdump = 0;
 	unsigned long lmb_size, base, size, sz;
 	int nid;
#1 lore raw
Quoted 16 lines · Michael Neuling

chroma_defconfig currently gives me this with gcc 4.6:
arch/powerpc/mm/numa.c:638:13: error: 'dm' may be used uninitialized in this function [-Werror=uninitialized]

It's a bogus warning since of_get_drconf_memory() only writes it anyway.

---
Also affects 3.4 and 3.3 stable.

arch/powerpc/mm/numa.c +0 -0
index 5ca3a15..880acde 100644

arch/powerpc/mm/numa.c static inline int __init read_usm_ranges(const u32 **usm) · line 640

Quoted 5 lines
arch/powerpc/mm/numa.c +1 -1
@@ -637,7 +637,7 @@ static inline int __init read_usm_ranges(const u32 **usm)
  */
 static void __init parse_drconf_memory(struct device_node *memory)
 {
-	const u32 *dm, *usm;
+	const u32 *dm = NULL, *usm;

Woot bikeshed! I think that's what the uninitialized_var() macro is for.

Yours Tony

#2 lore raw
Quoted 12 lines · Tony Breeds
Quoted 11 lines · Michael Neuling

chroma_defconfig currently gives me this with gcc 4.6:
arch/powerpc/mm/numa.c:638:13: error: 'dm' may be used uninitialized in this function [-Werror=uninitialized]

It's a bogus warning since of_get_drconf_memory() only writes it anyway.

---
Also affects 3.4 and 3.3 stable.

Quoted 12 lines

arch/powerpc/mm/numa.c static inline int __init read_usm_ranges(const u32 **usm) · line 640

Quoted 10 lines
arch/powerpc/mm/numa.c +1 -1
index 5ca3a15..880acde 100644
@@ -637,7 +637,7 @@ static inline int __init read_usm_ranges(const u32 **usm)
  */
 static void __init parse_drconf_memory(struct device_node *memory)
 {
-	const u32 *dm, *usm;
+	const u32 *dm = NULL, *usm;

Woot bikeshed! I think that's what the uninitialized_var() macro is for.

Doesn't work here. Produces the same error.

Mikey

#3 lore raw

PATCH 1/1 powerpc: fix uninitialised error in numa.c

chroma_defconfig currently gives me this with gcc 4.6:
arch/powerpc/mm/numa.c:638:13: error: 'dm' may be used uninitialized in this function [-Werror=uninitialized]

It's a bogus warning/error since of_get_drconf_memory() only writes it anyway.

---

Quoted 8 lines
Quoted 6 lines

Review

Quoted 4 lines

static void __init parse_drconf_memory(struct device_node *memory) {

(quoted diff) +1 -1
-	const u32 *dm, *usm;
+	const u32 *dm = NULL, *usm;

Woot bikeshed! I think that's what the uninitialized_var() macro is for.

Doesn't work here. Produces the same error.

My bad.. I was using it wrong

Still affects 3.4 and 3.3 stable.

arch/powerpc/mm/numa.c +1 -1
index 5ca3a15..7c28589 100644
@@ -637,7 +637,7 @@ static inline int __init read_usm_ranges(const u32 **usm)
  */
 static void __init parse_drconf_memory(struct device_node *memory)
 {
-	const u32 *dm, *usm;
+	const u32 *uninitialized_var(dm), *usm;
 	unsigned int n, rc, ranges, is_kexec_kdump = 0;
 	unsigned long lmb_size, base, size, sz;
 	int nid;