mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] i386 zone_sizes_init() fix
@ 2006-04-01 13:10 Wu Fengguang
  2006-04-01 15:04 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Wu Fengguang @ 2006-04-01 13:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

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.

Signed-off-by: Wu Fengguang <wfg@mail.ustc.edu.cn>
---

--- linux-2.6.16-mm2.orig/arch/i386/mm/discontig.c
+++ linux-2.6.16-mm2/arch/i386/mm/discontig.c
@@ -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;
 
--- linux-2.6.16-mm2.orig/arch/i386/kernel/setup.c
+++ linux-2.6.16-mm2/arch/i386/kernel/setup.c
@@ -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;

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

* Re: [PATCH] i386 zone_sizes_init() fix
  2006-04-01 13:10 [PATCH] i386 zone_sizes_init() fix Wu Fengguang
@ 2006-04-01 15:04 ` Andreas Schwab
  2006-04-02  0:58   ` Wu Fengguang
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2006-04-01 15:04 UTC (permalink / raw)
  To: Wu Fengguang; +Cc: Andrew Morton, linux-kernel

Wu Fengguang <wfg@mail.ustc.edu.cn> writes:

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

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
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."

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

* Re: [PATCH] i386 zone_sizes_init() fix
  2006-04-01 15:04 ` Andreas Schwab
@ 2006-04-02  0:58   ` Wu Fengguang
  0 siblings, 0 replies; 3+ messages in thread
From: Wu Fengguang @ 2006-04-02  0:58 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Andrew Morton, linux-kernel

On Sat, Apr 01, 2006 at 05:04:47PM +0200, Andreas Schwab wrote:
> Wu Fengguang <wfg@mail.ustc.edu.cn> writes:
> 
> > 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

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

end of thread, other threads:[~2006-04-02  0:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-01 13:10 [PATCH] i386 zone_sizes_init() fix Wu Fengguang
2006-04-01 15:04 ` Andreas Schwab
2006-04-02  0:58   ` Wu Fengguang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome