Skip to contentSkip to conversation

Fix 'zone_id' may be used uninitialized in this function warning

PATCH Applied Nico Pache 1 participant 1 message Jul 16, 2021

Subsystems (2)
lore
Share & tools
lore

Nico Pache

author
#0 lore raw

PATCH 1/1 Fix 'zone_id' may be used uninitialized in this function warning

When compiling with -Werror, cc1 will warn that 'zone_id' may be used uninitialized in this function warning.

Initialize the zone_id as 0.

Its safe to assume that if the code reaches this point it has at least one numa node with memory, so no need for an assertion before init_unavilable_range.

Fixes 122e093c1734 ("mm/page_alloc: fix memory map initialization for descending nodes")
---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
index 3e97e68aef7a..3f3116f52fd8 100644
@@ -6719,7 +6719,7 @@ static void __init memmap_init(void)
 {
 	unsigned long start_pfn, end_pfn;
 	unsigned long hole_pfn = 0;
-	int i, j, zone_id, nid;
+	int i, j, zone_id = 0, nid;
 
 	for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) {
 		struct pglist_data *node = NODE_DATA(nid);
Signature · 1 line
2.31.1