Skip to contentSkip to conversation

i386 zone_sizes_init() fix

PATCH In review Wu Fengguang 2 participants 3 messages Apr 1, 2006 – Apr 2, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386 zone_sizes_init() fix

Now that with MAX_NR_ZONES=4, the last element of zones_size[] is left uninitialized in zone_sizes_init() on i386.

Fix this by using gcc's range initializer to protect from future changes.

---

arch/i386/mm/discontig.c +1 -1
@@ -355,7 +355,7 @@ void __init zone_sizes_init(void)
 
 
 	for_each_online_node(nid) {
-		unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+		unsigned long zones_size[] = { [0 ... MAX_NR_ZONES-1] = 0 };
 		unsigned long *zholes_size;
 		unsigned int max_dma;
 
arch/i386/kernel/setup.c +1 -1
@@ -1203,7 +1203,7 @@ static unsigned long __init setup_memory
 
 void __init zone_sizes_init(void)
 {
-	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+	unsigned long zones_size[] = { [0 ... MAX_NR_ZONES-1] = 0 };
 	unsigned int max_dma, low;
 
 	max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
#1 lore raw
Quoted 2 lines · Wu Fengguang

Now that with MAX_NR_ZONES=4, the last element of zones_size[] is left uninitialized in zone_sizes_init() on i386.

No, it isn't. In the presence of an initializer any element not explicitly initialized will be set to 0 of the appropriate type.

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#2 lore raw
Quoted 7 lines · Andreas Schwab
Quoted 2 lines · Wu Fengguang

Now that with MAX_NR_ZONES=4, the last element of zones_size[] is left uninitialized in zone_sizes_init() on i386.

No, it isn't. In the presence of an initializer any element not explicitly initialized will be set to 0 of the appropriate type.

Got it, thanks for the tip.

Wu