Trivial fix to remove compiler warning
src/northbridge/amd/lx/raminit.c:302: warning: ‘spd_byte’ may be used uninitialized in this function
Signed-off-by: Nathan Williams nathan@traverse.com.au
diff --git a/src/northbridge/amd/lx/raminit.c b/src/northbridge/amd/lx/raminit.c index 7240898..1dd6d19 100644 --- a/src/northbridge/amd/lx/raminit.c +++ b/src/northbridge/amd/lx/raminit.c @@ -299,7 +299,8 @@ static void setCAS(void) ;* Destroys: We really use everything ! ;*****************************************************************************/ uint16_t glspeed; - uint8_t spd_byte, casmap0, casmap1; + uint8_t casmap0, casmap1; + uint8_t spd_byte = 0; msr_t msr;
glspeed = GeodeLinkSpeed();
Am 29.10.2010 07:58, schrieb Nathan Williams:
Trivial fix to remove compiler warning
Thank you for the patch. However, I think it has a risk of hiding real issues. Right now, the only case where spd_byte is uninitialized is the "else" clause, which runs into an endless loop (via hcf()). Your gcc version doesn't seem to detect that for some reason. Should the code change, and some other case leaves spd_byte untouched, without coreboot giving up, we get a value of 0 instead of a compile time error.
As I can't reproduce the warning (probably because my gcc version 4.4.4 detects that all cases either initialize spd_byte or never use it), could you please test the following change instead (with your patch reverted)? This explicitely tells the compiler that hcf won't return, so it should figure out that spd_byte is never used without being initialized even without knowing that while(1) { no break statement } is an endless loop.
Thanks, Patrick
Index: src/northbridge/amd/lx/raminit.c =================================================================== --- src/northbridge/amd/lx/raminit.c (Revision 6066) +++ src/northbridge/amd/lx/raminit.c (Arbeitskopie) @@ -32,7 +32,7 @@ printk(BIOS_DEBUG, " * %s\n", s); }
-static void hcf(void) +static void __attribute__((noreturn)) hcf(void) { print_emerg("DIE\n"); /* this guarantees we flush the UART fifos (if any) and also