* Build break (uninitialized variable)
@ 2012-02-03 18:26 Grégoire Sutre
2012-02-04 22:31 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 1 reply; 3+ messages in thread
From: Grégoire Sutre @ 2012-02-03 18:26 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 1613 bytes --]
The compiler complains about `totsize' being possibly uninitialized
in grub-core/disk/diskfilter.c, function grub_diskfilter_make_raid().
I get this error with gcc 4.5.3 on NetBSD, and also with gcc 4.6.2 on
Debian GNU/Linux.
I'm not familiar with that code. The attached patch fixes this by
returning NULL when the argument `level' has an unexpected value.
Grégoire
gcc -DHAVE_CONFIG_H -I. -I.. -Wall -W -I../include -I../include
-DGRUB_MACHINE_PCBIOS=1 -DGRUB_MACHINE=I386_PC -DGRUB_TARGET_CPU_I386=1
-m32 -DGRUB_FILE=\"disk/diskfilter.c\" -I. -I. -I.. -I.. -I../include
-I../include -Os -Wall -W -Wshadow -Wpointer-arith
-Wmissing-prototypes -Wundef -Wstrict-prototypes -g -falign-jumps=1
-falign-loops=1 -falign-functions=1 -mno-mmx -mno-sse -mno-sse2
-mno-3dnow -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -m32
-fno-stack-protector -mno-stack-arg-probe -Werror -mrtd -mregparm=3
-ffreestanding -MT disk/diskfilter_module-diskfilter.o -MD -MP -MF
disk/.deps-core/diskfilter_module-diskfilter.Tpo -c -o
disk/diskfilter_module-diskfilter.o `test -f 'disk/diskfilter.c' || echo
'./'`disk/diskfilter.c
cc1: warnings being treated as errors
disk/diskfilter.c: In function 'grub_diskfilter_make_raid':
disk/diskfilter.c:813:17: error: 'totsize' may be used uninitialized in
this function
gmake[3]: *** [disk/diskfilter_module-diskfilter.o] Error 1
gmake[3]: Leaving directory `/tmp/grub/grub-core'
gmake[2]: *** [all] Error 2
gmake[2]: Leaving directory `/tmp/grub/grub-core'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/tmp/grub'
gmake: *** [all] Error 2
[-- Attachment #2: diskfilter-totsize.diff --]
[-- Type: text/x-patch, Size: 407 bytes --]
=== modified file 'grub-core/disk/diskfilter.c'
--- grub-core/disk/diskfilter.c 2012-01-29 13:28:01 +0000
+++ grub-core/disk/diskfilter.c 2012-02-03 18:21:07 +0000
@@ -837,6 +837,9 @@ grub_diskfilter_make_raid (grub_size_t u
case 6:
totsize = (nmemb - level / 3) * disk_size;
break;
+
+ default:
+ return NULL;
}
array = grub_diskfilter_get_vg_by_uuid (uuidlen, uuid);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Build break (uninitialized variable)
2012-02-03 18:26 Build break (uninitialized variable) Grégoire Sutre
@ 2012-02-04 22:31 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-05 0:31 ` Grégoire Sutre
0 siblings, 1 reply; 3+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-02-04 22:31 UTC (permalink / raw)
To: The development of GNU GRUB; +Cc: Grégoire Sutre
On 03.02.2012 19:26, Grégoire Sutre wrote:
> The compiler complains about `totsize' being possibly uninitialized
> in grub-core/disk/diskfilter.c, function grub_diskfilter_make_raid().
> I get this error with gcc 4.5.3 on NetBSD, and also with gcc 4.6.2 on
> Debian GNU/Linux.
>
> I'm not familiar with that code. The attached patch fixes this by
> returning NULL when the argument `level' has an unexpected value.
>
I've looked at other code and seen that return NULL will result in the
skipping of those devices altogether, exactly what we want. So I think
it's a reasonable behaviour for this function. So go ahead
> Grégoire
>
> gcc -DHAVE_CONFIG_H -I. -I.. -Wall -W -I../include -I../include
> -DGRUB_MACHINE_PCBIOS=1 -DGRUB_MACHINE=I386_PC
> -DGRUB_TARGET_CPU_I386=1 -m32 -DGRUB_FILE=\"disk/diskfilter.c\" -I.
> -I. -I.. -I.. -I../include -I../include -Os -Wall -W -Wshadow
> -Wpointer-arith -Wmissing-prototypes -Wundef -Wstrict-prototypes -g
> -falign-jumps=1 -falign-loops=1 -falign-functions=1 -mno-mmx -mno-sse
> -mno-sse2 -mno-3dnow -fno-dwarf2-cfi-asm
> -fno-asynchronous-unwind-tables -m32 -fno-stack-protector
> -mno-stack-arg-probe -Werror -mrtd -mregparm=3 -ffreestanding
> -MT disk/diskfilter_module-diskfilter.o -MD -MP -MF
> disk/.deps-core/diskfilter_module-diskfilter.Tpo -c -o
> disk/diskfilter_module-diskfilter.o `test -f 'disk/diskfilter.c' ||
> echo './'`disk/diskfilter.c
> cc1: warnings being treated as errors
> disk/diskfilter.c: In function 'grub_diskfilter_make_raid':
> disk/diskfilter.c:813:17: error: 'totsize' may be used uninitialized
> in this function
> gmake[3]: *** [disk/diskfilter_module-diskfilter.o] Error 1
> gmake[3]: Leaving directory `/tmp/grub/grub-core'
> gmake[2]: *** [all] Error 2
> gmake[2]: Leaving directory `/tmp/grub/grub-core'
> gmake[1]: *** [all-recursive] Error 1
> gmake[1]: Leaving directory `/tmp/grub'
> gmake: *** [all] Error 2
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Build break (uninitialized variable)
2012-02-04 22:31 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2012-02-05 0:31 ` Grégoire Sutre
0 siblings, 0 replies; 3+ messages in thread
From: Grégoire Sutre @ 2012-02-05 0:31 UTC (permalink / raw)
To: grub-devel
On 02/04/2012 11:31 PM, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> On 03.02.2012 19:26, Grégoire Sutre wrote:
>> The compiler complains about `totsize' being possibly uninitialized
>> in grub-core/disk/diskfilter.c, function grub_diskfilter_make_raid().
>> I get this error with gcc 4.5.3 on NetBSD, and also with gcc 4.6.2 on
>> Debian GNU/Linux.
>>
>> I'm not familiar with that code. The attached patch fixes this by
>> returning NULL when the argument `level' has an unexpected value.
>>
> I've looked at other code and seen that return NULL will result in the
> skipping of those devices altogether, exactly what we want. So I think
> it's a reasonable behaviour for this function. So go ahead
I've committed the patch. Thanks for looking into this.
Grégoire
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-02-05 0:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-03 18:26 Build break (uninitialized variable) Grégoire Sutre
2012-02-04 22:31 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-05 0:31 ` Grégoire Sutre
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.