Skip to contentSkip to conversation

use of grub_dprintf in grub_mm_init_region() is misleading

PATCH In review Robert Millan 2 participants 2 messages Jan 23, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 use of grub_dprintf in grub_mm_init_region() is misleading

Using grub_dprintf() in grub_mm_init_region() easily leads to think that one can activate this debug message by issuing `grub_env_set ("debug", "mem")' in grub_machine_init(), before memory initialisation.

However, that's completely false. grub_env_set will silently [1] ignore your call because grub_malloc() ain't usable, possibly making you think for a while that no free memory was found, and that memory was not initialized at all!

I propose turning it into a disabled grub_printf().

[1] well, it'll return an error code. but who remembers about checking that?

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
	* kern/mm.c (grub_mm_init_region): Replace grub_dprintf() call with
	#ifdef'ed out grub_printf().
kern/mm.c renamed from grub2/kern/mm.c +3 -1
diff -x CVS -x '*~' -x '*.mk' -urp ../grub2/kern/mm.c ./kern/mm.c
@@ -143,7 +143,9 @@ grub_mm_init_region (void *addr, grub_si
   grub_mm_header_t h;
   grub_mm_region_t r, *p, q;
 
-  grub_dprintf ("mem", "Using memory for heap: start=%p, end=%p\n", addr, addr + (unsigned int) size);
+#if 0
+  grub_printf ("Using memory for heap: start=%p, end=%p\n", addr, addr + (unsigned int) size);
+#endif
 
   /* If this region is too small, ignore it.  */
   if (size < GRUB_MM_ALIGN * 2)
#1 lore raw
Quoted 9 lines · Robert Millan

Using grub_dprintf() in grub_mm_init_region() easily leads to think that one can activate this debug message by issuing `grub_env_set ("debug", "mem")' in grub_machine_init(), before memory initialisation.

However, that's completely false. grub_env_set will silently [1] ignore your call because grub_malloc() ain't usable, possibly making you think for a while that no free memory was found, and that memory was not initialized at all!

I propose turning it into a disabled grub_printf().

Fine for me.

--
Marco