Skip to contentSkip to conversation

Uninitialized variable

PATCH In review Grégoire Sutre 2 participants 2 messages Sep 23, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Uninitialized variable

Hi,

This is catched (as a warning) by gcc 4.1.3 -- gcc 4.4 does not complain (maybe some command-line option is missing?).

Grégoire

2010-09-23 Grégoire Sutre <[email protected]>

* grub-core/commands/acpihalt.c (get_sleep_type): Initialize prev.

=== modified file 'grub-core/commands/acpihalt.c'

commands/acpihalt.c +1 -1
@@ -134,11 +134,11 @@ skip_ext_op (const grub_uint8_t *ptr, co
 }
 
 static int
 get_sleep_type (grub_uint8_t *table, grub_uint8_t *end)
 {
-  grub_uint8_t *ptr, *prev;
+  grub_uint8_t *ptr, *prev = 0;
   int sleep_type = -1;
 
   ptr = table + sizeof (struct grub_acpi_table_header);
   while (ptr < end && prev < ptr)
     {
#1 lore raw
Quoted 16 lines · Grégoire Sutre

Hi,

This is catched (as a warning) by gcc 4.1.3 -- gcc 4.4 does not complain (maybe some command-line option is missing?).

Grégoire

2010-09-23 Grégoire Sutre <[email protected]>

* grub-core/commands/acpihalt.c (get_sleep_type): Initialize prev.

=== modified file 'grub-core/commands/acpihalt.c'

commands/acpihalt.c 2010-09-23 13:23:46 +0000 skip_ext_op (const grub_uint8_t *ptr, co · line 141

Quoted 9 lines
commands/acpihalt.c 2010-09-23 13:23:46 +0000 renamed from commands/acpihalt.c 2010-09-13 18:29:15 +0000 +1 -1
@@ -134,11 +134,11 @@ skip_ext_op (const grub_uint8_t *ptr, co
 }
 
 static int
 get_sleep_type (grub_uint8_t *table, grub_uint8_t *end)
 {
-  grub_uint8_t *ptr, *prev;
+  grub_uint8_t *ptr, *prev = 0;
   int sleep_type = -1;
 

It should be prev = table; Other than that go ahead.

Quoted 11 lines
commands/acpihalt.c 2010-09-23 13:23:46 +0000 renamed from commands/acpihalt.c 2010-09-13 18:29:15 +0000 +0 -0
   ptr = table + sizeof (struct grub_acpi_table_header);
   while (ptr < end && prev < ptr)
     {

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko